#include "apue.h"
#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);
}
我下載了apue.h文件,它在當前目錄中作爲我的源文件。當我嘗試使用clang和OS X進行編譯時,會發生以下錯誤。unix示例中的高級編程ls(1)命令錯誤
1 warning generated.
Undefined symbols for architecture x86_64:
"_err_quit", referenced from:
_main in lsnew-cbcc3e.o
"_err_sys", referenced from:
_main in lsnew-cbcc3e.o
ld: symbol(s) not found for architecture x86_64
clang error: linker command failed with exit code 1 (use -v to see invocation)
有人可以引導我正確的方向,以什麼是錯的?此代碼是否僅適用於32位系統?
謝謝。
'我下載了apue.h ...它不需要鏈接到一個實際庫嗎? – ThingyWotsit