Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Read the file called DISCLAIMER.

Some source changes needed to be made after the book went out for the first
printing.  I forgot to make corresponding changes in the source tree on the
system used to develop the book.  The changes are summarized below.

1. lib/recvfd.c and sockets/recvfd.c - needed sys/uio.h on Mac OS X
2. lib/sendfd.c and sockets/sendfd.c - needed sys/uio.h on Mac OS X
3. stdio/buf.c - added code for Mac OS X
4. threadctl/suspend.c - changed wait to waitloc to avoid symbol definition
	clash on Solaris
5. include/apue.h - FreeBSD compiles work better if we rely on the default
	system settings.  Solaris needed a different XOPEN_SOURCE definition
	and also a CMSG_LEN definition.

To build the source, edit the Make.defines.* file for your system and set
WKDIR to the pathname of the tree containing the source code.  Then just
run "make".  It should figure out the system type and build the source for
that platform automatically.  If you are running on a system other than
FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles
to include the settings for your system.  Also, you'll probably need to
modify the source code to get it to build on a different operating system.
The example source was compiled and tested using FreeBSD 5.2.1, Linux 2.4.22,
Mac OS X 10.3, and Solaris 9.

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

Steve Rago
May 30, 2005


一:整体编译:

1.APUE2源代码下载:
2.我保存到了/home/wx下.解压缩:tar zxvf src.tar.gz
3.cd apue.2e到apue.2e目录(查看README,告诉我们linux系统只要修改Make.defines.linux再make)
4.vi Make.defines.linux 修改WKDIR=/home/wx/apue.2e 就是说工作目录为WKDIR=/home/wx/apue.2e
5.修改/home/wx/apue.2e/std/linux.mk把全部的nawk改为awk.因些linux默认没有nawk
6.cd /home/wx/apue.2e

   make

7.stropts.h
如果出现stropts.h缺失的情况,则下载glibc-2.11,解压
cp ./glibc-2.11/streams/stropts.h /usr/include
cp ./glibc-2.11/bits/stropts.h /usr/include/bits
cp ./glibc-2.11/sysdeps/x86_64/bits/xtitypes.h /usr/include/bits

glibc-2.11下载地址:http://ftp.gnu.org/pub/gnu/glibc/glibc-2.11.tar.gz
(本版本文件中已附上)

8.ARG_MAX
如果在编译时提示ARG_MAX未定义,可以修改如下:
在apue.2e/include/apue.h中添加一行:
#define ARG_MAX 4096
打开apue.2e/threadctl/getenv1.c 和apue.2e/threadctl/getenv3.c,添加一行:
#include "apue.h"
(本版本已修改)


7.把生成的apue.2e/lib/libapue.a与apue.2e/include/apue.h拷贝到你编写的源代码目录下。

   (注:你可以把libapue.a和apue.h保存在容易找到的文件夹中,以便使用)

8.使用gcc -o ls1 ls1.c libapue.a来编译你的源代码
9.成功