開發環境:CentOS-7.7-1908,gcc version 4.8.5 20150623
UNIX高級環境編程的源代碼下載地址:http://apuebook.com/code3e.html
源代碼壓縮包:src.3e.tar.gz
在CentOS-7.7下解壓源代碼文件後進行編譯,報錯信息爲:
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE barrier.c -o barrier -L../lib -lapue -pthread -lrt -lbsd
/tmp/cc6Z8vzR.o: In function `thr_fn':
barrier.c:(.text+0x80): undefined reference to `heapsort'
collect2: error: ld returned 1 exit status
make[1]: *** [barrier] Error 1
發現heapsort在CentOS-7下沒有相關的庫,只能下載Fedora的資源進行安裝。
- RHEL/CentOS 7:
- # yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
然後執行
[root@localhost threads]# yum install libbsd libbsd-devel
即可編譯成功。