本文轉載自:http://blog.csdn.net/hadas_wang/article/details/43203795html
1. 下載代碼:http://www.apuebook.com/code3e.htmlui
2. 安裝依賴庫:sudo apt-get install libbsd-dev spa
3. 進入下載目錄make.net
4. 複製頭文件和動態連接庫code
- sudo cp ./include/apue.h /usr/include/
- sudo cp ./lib/libapue.a /usr/local/lib/
- sudo cp ./lib/libapue.a /usr/lib/
5. 設置錯誤文件error.hhtm
- #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);
-
- void err_ret(const char *fmt, ...)
- {
- va_list ap;
-
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- }
-
-
- void err_sys(const char *fmt, ...)
- {
- va_list ap;
-
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- exit(1);
- }
-
-
- 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);
- }
-
-
- void err_dump(const char *fmt, ...)
- {
- va_list ap;
-
- va_start(ap, fmt);
- err_doit(1, errno, fmt, ap);
- va_end(ap);
- abort();
- exit(1);
- }
-
-
- void err_msg(const char *fmt, ...)
- {
- va_list ap;
-
- va_start(ap, fmt);
- err_doit(0, 0, fmt, ap);
- va_end(ap);
- }
-
-
- void err_quit(const char *fmt, ...)
- {
- va_list ap;
-
- va_start(ap, fmt);
- err_doit(0, 0, fmt, ap);
- va_end(ap);
- exit(1);
- }
-
-
- 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);
- fputs(buf, stderr);
- fflush(NULL);
- }
6. 註銷,重啓blog
7. 代碼文件ip
- #include "apue.h"
- #include "error.h"