UNIX高级环境编程:源码(apue)下载 编译和运行

整体上和unpv差不多,参见我的另一篇博文unpv13e

1.源码下载

最简单的方式:(wget工具实在太好用)

wget http://www.apuebook.com/src.3e.tar.gz

2.解压查看目录结构

sunxiaowu@sunxiaowu:~/Downloads/apue/apue.3e$ dir
advio       figlinks  lib                   printer   standards
daemons     filedir   Make.defines.freebsd  proc      stdio
datafiles   fileio    Make.defines.linux    pty       systype.sh
db          include   Make.defines.macos    README    termios
DISCLAIMER  intro     Make.defines.solaris  relation  threadctl
environ     ipc1      Makefile              signals   threads
exercises   ipc2      Make.libapue.inc      sockets
vim README

Read the file called DISCLAIMER.

On Freebsd, type "gmake".
On other platforms, type "make" (as long as this is gnu make).

For FAQs, updated source code, and the lost chapter, see http://www.apuebook.com.
Please direct questions, suggestions, and bug reports to sar@apuebook.com.

Steve Rago
January 2013

3.编译


make

timeout.c:119:5: warning: ‘condition’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (condition) {
     ^
timeout.c:125:34: warning: ‘arg’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   timeout(&when, retry, (void *)((unsigned long)arg));
                                  ^
make[1]: Leaving directory `/home/sunxiaowu/Downloads/apue/apue.3e/threadctl'
making threads
make[1]: Entering directory `/home/sunxiaowu/Downloads/apue/apue.3e/threads'
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
make[1]: *** [badexit2] Error 1
make[1]: Leaving directory `/home/sunxiaowu/Downloads/apue/apue.3e/threads'
make: *** [all] Error 1

大部分编译通过,但最后出现以上错误,可以看出threads模块下的badexit2.c文件编译失败。原因是操作系统的限制,我的使用ubunu14.04,要想编译这个文件,需要在bsd下(还有些模块编译不通过,大部分都是这个原因,有兴趣的读者可以在其他操作系统下试试)

4.运行

sunxiaowu@sunxiaowu:~/Downloads/apue/apue.3e$ cd intro/
sunxiaowu@sunxiaowu:~/Downloads/apue/apue.3e/intro$ dir
getcputc    hello.c  Makefile  shell1    shell2.c     uidgid
getcputc.c  ls1      mycat     shell1.c  testerror    uidgid.c
hello       ls1.c    mycat.c   shell2    testerror.c
sunxiaowu@sunxiaowu:~/Downloads/apue/apue.3e/intro$ ./hello 
hello world from process ID 9793
sunxiaowu@sunxiaowu:~/Downloads/apue/apue.3e/intro$


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五癫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值