advanced Programming for UNIX Environments (third edition) code compilation
This address: Http://blog.csdn.net/caroline_wendy
Date: 2014.10.2
1. Download code:http://www.apuebook.com/code3e.html
2. Install dependent libraries:sudo apt-get install Libbsd-dev
3. Go to the download directory make
4. Copying header files and dynamic link libraries
sudo cp./include/apue.h/usr/include/sudo CP./lib/libapue.a/usr/local/lib/sudo CP./lib/libapue.a/usr/lib/
5. Setting the
error file Error.h
#include "apue.h" #include <errno.h>/* for definition of errno */#include <stdarg.h>/* ISO C VARIABL e aruments */static void err_doit (int, int, const char *, va_list),/* * Nonfatal error related to a system call. * Print a message and return. */void Err_ret (const char *FMT, ...) {va_list ap; Va_start (AP, FMT); Err_doit (1, errno, FMT, AP); Va_end (AP);} /* * Fatal Error related to a system call. * Print a message and terminate. */void Err_sys (const char *FMT, ...) {va_list ap; Va_start (AP, FMT); Err_doit (1, errno, FMT, AP); Va_end (AP); Exit (1);} /* * Fatal error unrelated to a system call. * Error code passed as explict parameter. * Print a message and terminate. */void err_exit (int error, const char *FMT, ...) {va_list ap; Va_start (AP, FMT); Err_doit (1, error, FMT, AP); Va_end (AP); Exit (1);} /* * Fatal Error related to a system call. * Print a message, dump core, and terminate. */void err_dump (const char *FMT, ...){va_list ap; Va_start (AP, FMT); Err_doit (1, errno, FMT, AP); Va_end (AP); Abort (); /* Dump core and Terminate */exit (1); /* shouldn ' t get here */}/* * nonfatal error unrelated to a system call. * Print a message and return. */void err_msg (const char *FMT, ...) {va_list ap; Va_start (AP, FMT); Err_doit (0, 0, FMT, AP); Va_end (AP);} /* * Fatal error unrelated to a system call. * Print a message and terminate. */void err_quit (const char *FMT, ...) {va_list ap; Va_start (AP, FMT); Err_doit (0, 0, FMT, AP); Va_end (AP); Exit (1);} /* Print a message and return to caller. * Caller Specifies "Errnoflag". */static void Err_doit (int errnoflag, int error, const char *FMT, va_list ap) {char buf[maxline]; vsnprintf (buf, MAXLINE, FMT, AP); if (Errnoflag) snprintf (Buf+strlen (BUF), Maxline-strlen (BUF), ":%s", strerror (Error)); strcat (buf, "\ n"); Fflush (stdout); /* In case stdout and stderr is the same*/fputs (buf, stderr); Fflush (NULL); /* Flushes all stdio output streams */}
6. Logout, restart
7. Code files
#include "apue.h" #include "error.h"
Linux-unix Environment Advanced Programming (third edition) code compilation