Unix高级编程实例编译方法

本文由博主原创,转载请注明出处(保留此处和链接):

一日二十四挨踢http://1024it.net/?p=241




下载链接:http://www.apuebook.com/  我这里下载2005版本

编译平台:ubuntu 12.04

把下载的 src.2e.tar.gz 复制到  ~/workspace/c_wspace/unix$  (这里改为你自己的工作目录),解压生成 apue.2e目录,进入后使用make linux 编译



遇到问题:

Q1:

robin@ubuntu:~/workspace/c_wspace/unix/apue.2e$ make linux
for i in lib sockets advio call calld daemons datafiles db environ exercises file ipc ipp lock mycat open opend opend.fe open.fe proc pty sess signals std stdio streams termios threadctl threads; do \
		(cd $i && make -f linux.mk) || exit 1; \
	done
make[1]: Entering directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e/lib'
gcc -DLINUX -ansi -I/home/sar/apue.2e/include -Wall -D_GNU_SOURCE   -c -o bufargs.o bufargs.c
bufargs.c:1:18: fatal error: apue.h: No such file or directory
compilation terminated.
make[1]: *** [bufargs.o] Error 1
make[1]: Leaving directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e/lib'
make: *** [linux] Error 1

A1:

  6 #WKDIR=/home/sar/apue.2e       
  7 WKDIR=/home/robin/workspace/c_wspace/unix/apue.2e
注释掉第6行的WKDIR,改成自己的路径: /home/robin/workspace/c_wspace/unix/apue.2e

Q2:

In file included from /usr/include/i386-linux-gnu/bits/time.h:86:0,
                 from /usr/include/time.h:42,
                 from /usr/include/pthread.h:26,
                 from printd.c:11:
/usr/include/i386-linux-gnu/bits/timex.h:31:7: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘.’ token
make[2]: *** [printd.o] Error 1
make[2]: Leaving directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e/ipp'
make[1]: *** [linux] Error 1
make[1]: Leaving directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e'
make: *** [all] Error 2

A2:

解决方法见:解决方法 


Q3:

gcc -DLINUX -ansi -I/home/robin/workspace/c_wspace/unix/apue.2e/include -Wall -pthread -D_GNU_SOURCE   -c -o getenv1.o getenv1.c
getenv1.c:4:20: error: ‘ARG_MAX’ undeclared here (not in a function)
getenv1.c:4:13: warning: ‘envbuf’ defined but not used [-Wunused-variable]
make[2]: *** [getenv1.o] Error 1
make[2]: Leaving directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e/threadctl'
make[1]: *** [linux] Error 1
make[1]: Leaving directory `/media/2ndDisk/workspace/c_wspace/unix/apue.2e'
make: *** [all] Error 2

A3:

robin@ubuntu:~/workspace/c_wspace/unix/apue.2e$  vim threadctl/getenv1.c 
添加头文件 #include "apue.h"

robin@ubuntu:~/workspace/c_wspace/unix/apue.2e$ vim include/apue.h 
添加宏定义 #define   ARG_MAX  4096 

robin@ubuntu:~/workspace/c_wspace/unix/apue.2e$ vim threadctl/getenv3.c

添加头文件 #include "apue.h"



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值