|
最近正要研习<Advanced Programming in the UNIX Environment>,下载了代码,可就是在我的RH8.0上编译通不过.
比如这个文件:myls.c
#include <sys/types.h>
#include <dirent.h>
#include "ourhdr.h"
int main(int argc, char *argv[])
{
DIR *dp;
struct dirent *dirp;
if ( argc != 2 )
err_quit("a single argument (the directory name)"
" is required");
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);
}
其中的ourhdr.h是书中为方便而给定的统一的头文件,其中内容含有
void err_dump(const char *, ...); /* {App misc_source} */
void err_msg(const char *, ...);
void err_quit(const char *, ...);
void err_ret(const char *, ...);
void err_sys(const char *, ...);
我不知在函数声明的参数中写省略号对不对(应该不对吧),但至少应该算"声明"了吧.
可是当我编译前面那个myls.c文件时:
gcc myls.c
却出现如下错误提示信息:
/tmp/ccPfIjbp.o: In function `main':
/tmp/ccPfIjbp.o(.text+0x1f): undefined reference to `err_quit'
/tmp/ccPfIjbp.o(.text+0x53): undefined reference to `err_sys'
collect2: ld returned 1 exit status
我不知哪位大哥实际练习过<Advanced Programming in the UNIX Environment>的代码,请指教这到底是怎么回事,还需要改写哪些地方或设置.谢谢!! |
|