当前位置: 技术问答>linux和unix
unix环境高级编程2 源代码使用问题
来源: 互联网 发布时间:2015-12-23
本文导语: 我现在运行unix环境高级编程2 中的源代码,比如如下: #include "apue.h" #include 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) e...
我现在运行unix环境高级编程2 中的源代码,比如如下:
#include "apue.h"
#include
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("%sn", dirp->d_name);
closedir(dp);
exit(0);
}在我的工作目录中,我将apue.h头文件放入了,可是编译时提示 undefined reference to 'err_quit'和undefined reference to 'err_sys',请问这是为什么啊
#include "apue.h"
#include
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("%sn", dirp->d_name);
closedir(dp);
exit(0);
}在我的工作目录中,我将apue.h头文件放入了,可是编译时提示 undefined reference to 'err_quit'和undefined reference to 'err_sys',请问这是为什么啊
|
complile with apue.c
>> gcc youfile.c apue.c
>> gcc youfile.c apue.c
|
At the section Appendix B. Miscellaneous Source Code, part B.2 Standard Error Routines, please combine the following sources codes as apue.c
Figure B.3. Error functions that output to standard error
Figure B.4. Error functions for daemons
Regards
Figure B.3. Error functions that output to standard error
Figure B.4. Error functions for daemons
Regards