Apue source code usage
1. Download the source code and decompress it to http://www.apuebook.com/download the source code wget http://www.apuebook.com/src.tar.gz-P/usr/local/src
Decompress the source code to the specified path:/root/bin, which is specified by the-C parameter. decompress the package to generate the apue.2e directory in the specified directory.
Tar zxvf/usr/local/src/src.tar.gz-C/root/bin
2. Modify the working path and awk Tool Name
Vi/root/bin/apue.2e/Make. defines. linux
Change the WKDIR to the path strength we have extracted.
WKDIR =/root/bin/apue.2e
Vi/root/bin/apue.2e/std/linux. mk
Replace nawk with gawk.
Gawk-f makeconf. awk> conf. c
Gawk-f makeopt. awk> options. c
3. compile and generate the static library libapue.
Cd/root/bin/apue.2e/lib
Make-f linux. mk
If an "ARG_MAX" undefined error is reported during make, modify the apue. h file under the include directory and add a line: # define ARG_MAX 4096
Modify the threadctl/getenv1.c and threadctl/getenv3.c files, add # include "apue. h", and then make
4. Copy the corresponding file to the corresponding directory:
Static library file: libapue.
Header file: apue. h
Cp/root/bin/apue.2e/lib/libapue. a/usr/include/
Cp/root/bin/apue.2e/include/apue. h/usr/apue/include/
5. In this way, you can use # include <apue. h> in your own code. You need to add the-lapue option during compilation. For example, you need to compile hello. c:
Gcc hello. c-lapue-o hello