标签:
1 #include"apue.h" 2 #include<dirent.h> 3 4 int main(int argc,char *argv[]) 5 { 6 DIR *dp; 7 struct dirent *dirp; 8 9 if(argc != 2) 10 err_quit("usage:ls directroy_name:"); 11 if((dp = opendir(argv[1])) == NULL) 12 err_sys("can‘t open &s",argv[1]); 13 while ((dirp = readdir(dp)) != NULL) 14 printf("%s\n",dirp->d_name); 15 16 17 closedir(dp); 18 exit(0); 19 }
编译成功就是因为没有这个apue.h 头文件
需要去http://www.apuebook.com/code3e.html
用tar 指令解压到自己准备放的目录
$sudo apt-get install libbsd-dev
make
会出现问题:
:(.text+0x20): undefined reference to `err_quit‘
:(.text+0x5b): undefined reference to `err_sys‘
gcc时 加上gcc XX.c -lpaue
完毕
声明
感谢http://blog.csdn.net/abc5382334/article/details/18518423
http://blog.csdn.net/blitzskies/article/details/42171089大神~
标签:
原文地址:http://www.cnblogs.com/mrAAron/p/5426025.html