[UNIX环境高级编程](第三版)中apue.h的问题

编译 gcc -g myls.c 时,报错 ‘找不到头文件 apue.h’html

apue.h是做者本身写的一个文件,系统不自带。其中包含了经常使用的头文件,以及出错处理函数的定义。linux

 

须要到 http://www.apuebook.com/code3e.html(这本书的官网) 下载  ‘src.3e.tar.gz’windows

进行解压(最新版产生的目录apue.3e),并执行安装ide

tar -zvx -f src.3e.tar.gz函数

进入目录apue.3e,执行安装工具

./configure网站

makespa

make install.net

 

但当执行 make时报错code

make[1]: *** [barrier] 错误 1

解决方法:因为执行make时依赖于 libbsd这个库,须要安装 libbsd,

libbsd的官方解释:This library provides useful functions commonly found on BSD systems,

and lacking on others like GNU systems, thus making it easier to port projects with strong BSD origins,

without needing to embed the same code over and over again on each project.

个人理解是,Linux与Unix有必定的差别,libbs库提供了一些 Linux系统中缺乏的东西

 

libbsd库须要到 http://pkgs.org/search/?query=libbsd&type=smart 肯定下载的版本,执行安装(yum/apt-get)

或者下载到本地windows系统,经过ftp工具传送到Linux再安装

根据Linux的版本,下载相应的两个安装文件

例如CentOS 6系列/x86_64,须要下载

libbsd-0.6.0-1.el6.art.x86_64.rpm

libbsd-devel-0.6.0-1.el6.art.x86_64.rpm

而后按照顺序 安装便可

yum install libbsd-0.6.0-1.el6.art.x86_64.rpm

yum install libbsd-devel-0.6.0-1.el6.art.x86_64.rpm

 

再到apue.3e ,执行make、make install

此时会产生静态库文件 libapue.a,也就是最初报错缺乏的东西

cp /apue.3e/include/apue.h /usr/include/

cp ./lib/libapue.a  /usr/lib 

 

执行编译经过

gcc myls.c -o myls -lapue (编译须要链接静态库)

 

另分享一个rpm资源的网站,能够搜索linux各个版本的软件资源

http://rpm.pbone.net/ (底部分为4种模式查询)

 

完!

相关文章
相关标签/搜索