歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> 我的apue.h配置

我的apue.h配置

日期:2017/3/1 16:35:26   编辑:關於Linux
我的apue.h配置 在http://www.apuebook.com/下載src.tar.gz源代碼的壓縮包。 1、解壓至/home/目錄下 www.2cto.com 2、進入/home/apue.2e ,修改 Make.defines.linux中的WKDIR=/home/xxx/apue.2e,為WKDIR=/home/apue.2e 3、然後進入apue.2e/std 目錄,修改linux.mk,將裡面的nawk全部改為awk,可以使用這個命令 :%s/nawk/awk/g 4.然後把 /home/godsoul/apue.2e/inlcude 目錄下的 apue.h 文件和位於 /home/godsoul/apue.2e/lib 目錄下的 error.c 文件都復制到 /usr/include 目錄下 5. 最終還要編輯一下復制過來的 apue.h 文件 , 在最後一行 #endif 前面添加一行 #include “error.c” www.2cto.com 6.提示ARG_MAX未定義,可以這麼修改。 在apue.2e/include/apue.h中添加一行: #define ARG_MAX 4096 打開apue.2e/threadctl/getenv1.c 和apue.2e/threadctl/getenv3.c,添加一行: #include “apue.h” 7. 改好後make clean再重新make 8. 打開1-1程序,在#include "apue.h"下面加上一行#include "error.c" #include "apue.h" #include "error.c" #include <dirent.h> int main(int argc,char *argv[]) { DIR *dp; struct dirent *dirp; if(argc !=2) err_quit("usage:ls directory_name"); if((dp = opendir(argv[1])) == NULL) err_sys("can't open %s",argv[1]); while ((dirp = readdir(dp))!= NULL) printf("%s\n",dirp->d_name); closedir(dp); exit(0); }
Copyright © Linux教程網 All Rights Reserved