官方网站 : http://www.apuebook.com/
- 下载官网提供源码包
wget http://www.apuebook.com/src.3e.tar.gz
- 解压
tar -zxvf src.3e.tar.gz
- 编译
cd src.3e
make
- 发现错误
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE badexit2.c -o badexit2 -L../lib -lapue -pthread -lrt -lbsd
/usr/bin/ld: cannot find -lbsd
collect2: error: ld returned 1 exit status
Makefile:31: recipe for target 'badexit2' failed
make[1]: *** [badexit2] Error 1
make[1]: Leaving directory '/home/sun/Desktop/apue.3e/threads'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 1
- 解决方案
sudo apt-get install libbsd-dev
- 复制库到系统lib目录中
sudo cp ./include/apue.h /usr/include/
sudo cp ./lib/libapue.a /usr/local/lib/
参考资料 :