到目前为止,我已经开始阅读《UNIX®环境中的高级编程》这本书。我想尝试运行其第一个代码示例。我正在运行Scientific Linux 6.4。
我下载了源代码,并按自述make文件中的说明运行了未压缩的文件。
我写了第一个程序(一个模拟ls命令)
#include "./include/apue.h"
#include <dirent.h>
int
main(int argc, char *argv[])
{
    DIR           *dp;
    struct dirent *dirp;
    if(argc!=2)
        err_quit("usage: test 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);
    return 0;
}
并将其放在未压缩的文件中。正如书中所建议的那样,我随后进行了:gcc myls.c。但是我得到这个错误:
# gcc myls.c
/tmp/ccWTWS2I.o: In function `main':
test.c:(.text+0x20): undefined reference to `err_quit'
test.c:(.text+0x5b): undefined reference to `err_sys'
collect2: ld returned 1 exit status
我想知道如何解决此问题。我还希望能够运行在任何目录中编写的代码。
include,其头文件为apue.h。但这是该目录中的唯一文件。我不知道实际的函数定义在哪里!我以为有人可能在这里熟悉本书的源代码文件结构。
                .h文件包括功能的原型。它们的实现位于.so或.a需要显示在包装盒中的文件中。这些是包含功能的动态和静态库。
                apue.h什么?
                
err_{quit,sys}从哪里来?