Mac OS X 10.8 compiled APUE (Unix environment advanced programming) source code procedures

  • 2020-04-02 02:44:45
  • OfStack

Recently, I have been reviewing APUE (advanced programming in Unix environment). I used to do it under Linux, but now I plan to do it on my own machine. Therefore, I have done it by Google, and I have fixed some errors in some tutorials, such as download links.

1, download the source file, I here is the second edition, seems to be the third edition of the English version out...


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

2, decompression


tar zxf src.2e.tar.gz

3. Fix something


cd apue.2e/
vim Make.defines.macos
WKDIR=/Users/chenqing/apue.2e //Change the absolute path to your code
vim include/apue.h
In the first 11 Add the following three sentences after the line
#ifdef MACOS
 #define _DARWIN_C_SOURCE
 #endif

4, compile,


make all

5, copy,


sudo cp include/apue.h /usr/include/
sudo cp lib/error.c  /usr/include/

6. Modify apue. H

On the last line is #endif   Add a line #include "error.c"

7. Test it out


#include <apue.h>
int main()
{
         err_sys("some error found %d",getpid());          return 0 ; }


Related articles: