Just now I have began reading the book: Advanced Programming in the UNIX Environment. I wanted to try running its first code example. I am running Scientific Linux 6.4.I downloaded the source code and as it says in its README, I ran make in the uncompressed file. I wrote the first program (a mock ls command)#include ./include/apue.h#include <dirent.h>intmain(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;}and put it in the uncompressed file. As the book had advised I then ran: gcc myls.c. But I get this error:# 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 statusI wanted to know how I can fix this problem. I also want to be able to run a code I write in any directory, can anyone guide me on that too? 
Compiling code from apue
compiling
A short review of how to write and compile the programs in Advanced Programming in the UNIX Environment, thanks to slm for helping me understand the steps. You can download the source code from here.I wish this information was included as part of appendix b of the book,where the header file is explained.The uncompressed file contains directories with the names of the chapters and two others named include and lib. The ones with the names of the chapters have all the programs of that chapter in them. The include directory contains the header file thatis used in most of the programs in the book: apue.h.The lib directory has the source code of the implementations for the that header.Lets assume the uncompressed file is located at: SCADDRESS/, for example it might be: /home/yourid/Downloads/apue.3e/Once you uncompress the source code, go in the directory and run make:$ cd SCADDRESS$ makemake will compile all the programs in all the chapters.But the important thing is that before that, it will make the library that will contain the implementations of the functions in apue.h. To compile an example program that you write from the book, run this GCC command (assuming your program's name is myls.c which is the first in the book): gcc -o myls myls.c -I SCADDRESS/include/ -L SCADDRESS/lib/ -lapue-I tells gcc which directory to look for the include file.-L tells it the location of the library directory, and-lapue, tells the name of the library file to look forin that directory. Such that -LXXX means to look for a filein the library directory with the name: libXXX.a or libXXX.so. 