Linux下配置APUE的编译 报错之后如何处理
APUE即Unix环境高级编程,本书中几乎所有的程序都包含一个apue.h的头文件,那如何配置这个apue.h呢?
官方地址:http://www.apuebook.com/apue3e.html
1、我们可以在src.3e.tar中下载,然后放到你的Linux桌面上(没桌面的,随意放吧)
2、解压下载的文件:
tar -zxvf src.3e.tar.gz
3、进入解压后的目录:
cd apue.3e/
4、编译:
make
以下是我用centos 32 6.5 make 最新版第三版的错误:
[u1@h1 apue.3e]$ make
gcc -ansi -I../include -Wall -DLINUX
-D_GNU_SOURCE -c -o rwlock.o rwlock.c
gcc -ansi -I../include -Wall -DLINUX
-D_GNU_SOURCE timedlock.c -o timedlock -L../lib -lapue -pthread
-lrt -lbsd
gcc -ansi -I../include -Wall -DLINUX
-D_GNU_SOURCE barrier.c -o barrier -L../lib -lapue -pthread -lrt
-lbsd
/tmp/ccb9gvom.o: In function `thr_fn’:
barrier.c:(.text+0x6e): undefined reference to
`heapsort’
collect2: ld 返回 1
make[1]: *** [barrier] 错误 1
make[1]: Leaving directory
`/home/albert/Documents/progs/apue.3e/threads’
make: *** [all] 错误 1
[u1@h1 apue.3e]$
解决的方法:
1)ubuntu
sudo apt-get install libbsd-dev
2) fedora, redhat, centos
2.1) 下载两个包
2.1a) i386
wget
ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/i386/libbsd-0.6.0-1.el6.i686.rpm
wget ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/i386/libbsd-devel-0.6.0-1.el6.i686.rpm
2.1b) x86_64
wget
ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/libbsd-0.6.0-1.el6.x86_64.rpm
wget ftp://ftp.univie.ac.at/systems/linux/fedora/epel/6/x86_64/libbsd-devel-0.6.0-1.el6.x86_64.rpm
2.2)安装如上包,注意命令顺序,需要root权限
2.2a) i386
yum install libbsd-0.6.0-1.el6.i686.rpm
yum install libbsd-devel-0.6.0-1.el6.i686.rpm
2.2b) x86_64
yum install libbsd-0.6.0-1.el6.x86_64.rpm
yum install libbsd-devel-0.6.0-1.el6.x86_64.rpm2.3)然后继续编译apue
[u1@h1 apue.3e]$make
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE -c -o
asyncsocket.o asyncsocket.c
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE -c -o openmax.o
openmax.c
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE -c -o sleep.o
sleep.c
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE -c -o
sleepus_poll.o sleepus_poll.c
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE -c -o
sleepus_select.o sleepus_select.c
gcc -ansi -I../include -Wall -DLINUX -D_GNU_SOURCE getpwsvr4.c -o
getpwsvr4 -L../lib -lapue -pthread
make[1]: Leaving directory `/home/u1/Documents/progs/apue.3e/exercises’
[[u1@h1 apue.3e]$$
此时应该成功了,我们把apue.h 与 libapue.a 放入到对应的目录中,用如下命令完成:
cp ./include/apue.h /usr/include/
cp ./lib/libapue.a /usr/local/lib/
为什么要将libapue.a移到/usr/local/lib中呢?
原因是libapue.a是apue.h头文件中包含的所有函数及宏定义的具体实现,是一个静态链接库。
查看ld.conf.d/libc.conf你会发现gcc在搜索链接库的时候默认会去搜索/usr/local/lib/中的文件,所以我们将其放在这里,一劳永逸。。。。(不过自己要知道哦)
Linux下配置APUE的编译 报错之后如何处理的更多相关文章
- Linux下配置APUE的编译环境
APUE即Unix环境高级编程,本书中几乎所有的程序都包含一个apue.h的头文件,那如何配置这个apue.h呢? 1.我们可以在http://pan.baidu.com/s/1dDxmtbF中下载, ...
- Linux下登陆MySQL时遇到报错"RROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) "
前言 作者在2021-07-21时遇到 linux下登陆MySQL时遇到报错"RROR 1045 (28000): Access denied for user 'root'@'localh ...
- xocde7下导入libsqlite3.tbd编译报错的解决办法
在xocde7下没有libsqlite3.dylib,只有libsqlite3.tbd,然后我导入了tbd.编译报错error: /Applications/Xcode.app/Contents/De ...
- linux下TP5安装好Workerman 报错:Class 'think\worker\Server' not found
今天把功能放到服务器,本地测试正常,上传到服务器上报错Class 'think\worker\Server' not found 首先想到的是Windows和Linux下大小写的问题,查看了代码,并没 ...
- Linux下idea选择tomcat server 报错Warning the selected directory is not a valid tomcat home
这是文件的权限问题,在tomcat的目录下执行以下代码 sudo chmod 777 -R tomcat8/ 然后再去idea中配置即可
- 解决linux下sudo更改文件权限报错xxxis not in the sudoers file. This incident will be reported.
本文转自Linux社区作者为z-sm的文章 原文链接http://www.linuxidc.com/Linux/2016-07/133066.htm 之前一直使用的是ubuntu,后来安装了Cento ...
- linux 下 PHP Notice: session_start(): ps_files_cleanup_dir 报错 问题剖析
如果在ubuntu/Debian下, 采用apt安装的PHP, 那么在使用Session的时候, 就可能会有小概率遇到这个提示. 代码如下: PHP Notice: session_start(): ...
- 在Linux下JDK1.4.2安装报错的解决方法
JDK1.4.2的安装 Do you agree to the above license terms? [yes or no] yes Unpacking... tail: cann ...
- Aspose Linux下字体找不到报错
http://www.aspose.com/docs/display/cellsnet/Smart+Markers http://www.aspose.com/docs/display/cellsja ...
随机推荐
- 双击bin/startup.bat启动tomcat常见错误
双击bin/startup.bat启动tomcat常见错误: 常见错误:可能与其他服务的端口号冲突. tomcat的默认端口号8080,此端口号较为常见,建议修改此端口号. 修改方法: 点击conf文 ...
- ES6-21.class基本语法
1.简介(详情参考) class是构造函数的语法糖. class的constructor方法内的实现,就是原来构造函数的实现. class内的所有方法都是在prototype上的,就是原来构造函数的p ...
- Laravel API Errors and Exceptions: How to Return Responses
Laravel API Errors and Exceptions: How to Return Responses February 13, 2019 API-based projects are ...
- 037_自动添加防火墙规则,开启某些服务或端口(适用于 RHEL7)
#!/bin/bash#设置变量定义需要添加到防火墙规则的服务和端口号#使用 firewall-cmd --get-services 可以查看 firewall 支持哪些服务 service=&quo ...
- setsockopt函数
#include <sys/socket.h> int setsockopt( int socket, int level, int option_name, ...
- c++ 排序,<< 运算符重载
#include <iostream> #include <functional> #include <list> using namespace std; ost ...
- yquery-操作样式属性
前几天回家,参加了全国的成人高考,都说学历是找工作的敲门砖,其实一点都不假,尤其是现在的社会竞争力那么强,你不学就会被淘汰.像要过自己想要的生活,就必须努力学习,努力赚钱,买自己想买的,过自己想过的. ...
- struts2方法无法映射问题:There is no Action mapped for namespace [/] and action name [m_hi] associated with context path []
使用struts的都知道,下面使用通配符定义的方式很常见,并且使用也很方便: <action name="Crud_*" class="example.Crud&q ...
- 在树莓派4b上安装 ROS MELODIC 源码安装
按照以下步骤照做就可以了,很简单的,就是浪费一点点时间罢了.也可以退而求其次,买个树莓派3B+来玩,哈哈. Step 1: Install Dependecies and Download the P ...
- pwn学习日记Day6 基础知识积累
知识杂项 ELF:在计算机科学中,是一种用于二进制文件.可执行文件.目标代码.共享库和核心转储格式文件. char fgets(char buf, int bufsize, FILE stream); ...