[cs631apue] Archive state?

Jan Schaumann jschauma at stevens.edu
Mon Oct 7 23:58:10 EDT 2013


Tejas Nadkarni <tnadkarn at stevens.edu> wrote:
 
> gcc -o ls.o -c -g -Wall ls.c
> gcc -o lsfunc.o -c -g -Wall lsfunc.c
> gcc -o ls ls.o lsfunc.o -Wl,-rpath,/usr/local/lib
> lsfunc.o: In function `lsfiletype':
> /home/tnadkarn/tnadkarn_midterm_snapshot/lsfunc.c:446: undefined reference
> to `strmode'
> collect2: ld returned 1 exit status
> make: *** [ls] Error 1

Here, the linker (ld(1)) returns the error status, so this is in fact a
link-time error.

strmode(3) required that you link against the bsd library, but
unfortunately the manual page on this linux system does not mention
this.  (The quality of manual pages and other documentation on the Linux
systems lacks significantly compared to the various BSD systems.)

Add "-lbsd" to the arguments when you're linking your executable in the
last step.

-Jan


More information about the cs631apue mailing list