Linux-Unix環境進階編程(第三版)代碼編譯

來源:互聯網
上載者:User

Linux-Unix環境進階編程(第三版)代碼編譯
Unix環境進階編程(第三版) 代碼編譯

本文地址:http://blog.csdn.net/caroline_wendy

時間:2014.10.2

1. 下載代碼:http://www.apuebook.com/code3e.html

2. 安裝依賴庫:sudo apt-get install libbsd-dev

3. 進入下載目錄make

4. 複製標頭檔和動態連結程式庫

sudo cp ./include/apue.h /usr/include/sudo cp ./lib/libapue.a /usr/local/lib/sudo cp ./lib/libapue.a /usr/lib/
錯誤檔案error.h
#include "apue.h"#include <errno.h>      /* for definition of errno */#include <stdarg.h>     /* ISO C variable 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 are the same */   fputs(buf, stderr);   fflush(NULL);       /* flushes all stdio output streams */}

7. 代碼檔案

#include "apue.h"#include "error.h"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.