Linux-unix Environment Advanced Programming (third edition) code compilation

Source: Internet
Author: User

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 folder 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.