1. Download the source code in http://www.apuebook.com
2. View Read
[email protected]:/home/wl/mywork/apue.2e# cat-n README 1Read the file called DISCLAIMER. 2 3Some source changes needed to being made after the book went out for the first 4printing. I forgot to make corresponding changes in the source tree on the 5system used to develop the book. The changes is summarized below. 6 71. LIB/RECVFD.C and sockets/recvfd.c-needed sys/uio.h on Mac OS X 82. LIB/SENDFD.C and sockets/sendfd.c-needed sys/uio.h on Mac OS X 93. stdio/buf.c-added code for MAC OS X 104. threadctl/suspend.c-changed wait to waitloc-avoid symbol definition 11clash on Solaris 125. INCLUDE/APUE.H-FREEBSD compiles work better if we rely on the default 13system settings. Solaris needed a different Xopen_source definition 14and also a cmsg_len definition. 16To build the source, edit the make.defines.* file for your system and set 17WKDIR to the pathname of the tree C Ontaining the source code. Then just18run "make". It should the system type and build the source for 19that platform automatically. If you're running on a system other than 20FreeBSD, Linux, Mac OS X, or Solaris, you'll need to modify the makefiles 21to include the settings for your system. Also, you'll probably need to 22modify of the source code to get it to build on a different operating system. 23The example Source was compiled and tested using FreeBSD 5.2.1, Linux 2.4.22, 24Mac OS X 10.3, and Solaris 9. 26For FAQs, updated source code, and the lost chapter, see Http://www.apuebook.com. 27Please direct questions, suggestions, and bug reports to [email protected] 29Steve Rago 30May 30, 2005[ email protected]:/home/wl/mywork/apue.2e#
Starting from line 16th, you'll be able to see 19 rows.
3. Change Make.defines.linux
# Common make definitions, customized-platform# definitions required in all program directories to compile and Li nk# C programs using GCC. wkdir=/home/wl/mywork/apue.2e#WKDIR =/home/sar/apue.2ecc=gcccompile.c=$ (CC) $ (CFLAGS) $ (cppflags)- clink.c=$ (CC) $ (CFLAGS) $ (cppflags) $ (lddir) $ (ldflags) Lddir=-l: /libldlibs=. /lib/libapue.a $ (extralibs) cflags=-dlinux-ansi-i$ (Wkdir)/include-wall-d_gnu_source $ (EXTRA)CPPFLAGS=-I/home/ Wl/mywork/apue.2e/include# Our library, the almost every program needs. lib=. /libapue.a# Common temp files to delete from each directory. Tempfiles=core core.* *.o temp.* *.out typescript*~
You just need to change the big words to their own path to be able to ~ ~ ~
4. Copy the apue.h and error.c two files to/usr/include
5. Edit Apue.h
#vi apue.h
In the last line #endif/* _apue_h */
Add a row earlier #include "error.c".
6. Compiling the source file
(Take Source\file folder as an example)
#cd file
#cp linux.mk Makefile
#make
[email protected]:/home/wl/mywork/apue.2e/file# Makegcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall- D_gnu_source-i/home/wl/mywork/apue.2e/include-l. /lib ACCESS.C. /lib/libapue.a-o Accessgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue .2e/include-l. /lib CDPWD.C. /lib/libapue.a-o cdpwdgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib CHANGEMOD.C. /lib/libapue.a-o changemodgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib devrdev.c. /lib/libapue.a-o devrdevgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib FILEFLAGS.C. /lib/libapue.a-o fileflagsgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib filetype.c. /lib/libapue.a-o FILETYPEGCC -dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue.2e/include-l. /lib ftw4.c. /lib/libapue.a-o ftw4gcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib hello.c. /lib/libapue.a-o hellogcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib hole.c. /lib/libapue.a-o holegcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib longpath.c. /lib/libapue.a-o longpathgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib ls1.c. /lib/libapue.a-o ls1gcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue.2e /include-l. /lib MYCD.C. /lib/libapue.a-o Mycdgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue.2e/include-l. /lib seek.c. /lib/libapue.a-o seekgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib testerror.c. /lib/libapue.a-o testerrorgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib UIDGID.C. /lib/libapue.a-o Uidgidgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue .2e/include-l. /lib umask.c. /lib/libapue.a-o umaskgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/ Apue.2e/include-l. /lib unlink.c. /lib/libapue.a-o Unlinkgcc-dlinux-ansi-i/home/wl/mywork/apue.2e/include-wall-d_gnu_source-i/home/wl/mywork/apue .2e/include-l. /lib zap.c. /lib/libapue.a-o zap[email protected]:/home/wl/mywork/apue.2e/file#
Compilation succeeded
------------------------------------------------------------enjoy-------------------------------------------------------- -----------------------------
-----------------------------------------------------------the End-----------------------------------------------------------------------------------
Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.
The second version of the source code for the UNIX programming environment is under Ubuntu