Thanks to all who wrote back: Michael Schulte <mike@babbage.cs.umsl.edu> Ger Lawlor <gerard.lawlor@kapookigames.com> Hendrik Visage <hvisage@is.co.za> "Jonathan A. Zdziarski" <jonathan@networkdweebs.com> mike.salehi@kodak.com I was missing .c files and fuctions and libraries. For the Steven's book I was missing .c files from Appendix B. Also, had to define the debug level to 1 on the main programs. See emails below. I got the Steven's code compiling, though it is hard to read with so many dependencies all over the book. For the OReilly book and code I was also missing files and the inclusion of the -lgen library as an argument to gcc. However, these are harder for me to figure out since the missing files are defined and called from a Makedefs and a Makefile.solaris. These I have not managed to compiled clean... but I am getting close. The missing files are compiled to object code in the make and makedefs files. Just goot to dust-off my old O'Reilly Make book and get to work on it. Thanks for the help. Carlos Sevillano Michael Schulte <mike@babbage.cs.umsl.edu> ######## FOR STEVEN'S: This is a declaration, not a definition; it asserts that the function exists somewhere and how the function is called; it does not give the code. (Only a compiler geek would make the distinction.) This sounds like a Stevens-defined generic error routine. It is probable that there is a .c file somewhere in the set of files that you downloaded that contains the definition [the code]. You need to link that file in also. (It seems to me that I saw similar things in his old book about network programming.) FOR OREILLY: Same comment on outputLine and inputLine. They sould like generic I/O routines; the code is probably in another .c file that needs to be downloaded and linked in also. The man page for strtrns indicates that you also need to link in the gen library: gcc translate.c <other_c_files> -lgen Ger Lawlor <gerard.lawlor@kapookigames.com> ############## ... Steven's ... wrap the UNIX functionality into a single funcitonal unit of code. These should exist in the code section contained in the Appendix which has the header file code. Other places he writes functions and uses them in later chapters so you could be writing code from chapter 10 that contains a call to a function which was completed in Chapter 2. ld - this is the linker. If it finds a reference to a function that does not have a definition then it will output the errors below. If your trying to learn UNIx system programming you should write your own wrapper functions for the UNIX interfaces. Use the man pages to examine the system api prototypes and your on your way. Hendrik Visage <hvisage@is.co.za> ############### Please include the source code. I suspect there could either be a case of not including the correct libraries at link time, or you aren't including all the relevant header files. "Kevin P. Inscoe" <kevin@inscoe.org> ############### Have a look here this may help http://inscoe.org/compilesun "Jonathan A. Zdziarski" <jonathan@networkdweebs.com> ################## You must include the libraries that these functions exist in using the -l flag. For example, if a function I was using was part of libsocket.so.1, I would compile with -lsocket on the commandline. The header files merely declare the function, if you don't link to it then you won't be able to use it. The only exception to this is if you are creating a shared library in which case you specify that it is a shared library with the flag -dy and then your library will use the functions linked to the programs calling it. mike.salehi@kodak.com #################### err_sys, is not a unix library, its a subroutine that you write and I think the source code is in one of the appendices. ---- On Thu, 21 Feb 2002, Carlos Sevillano (carlos_sevillano@ureach.com) wrote: > I started learning UNIX system programming with some suggested books. > Some of > the better-rated books seem to problems with the code or code > implementation. For > example, here are two problems with the linking as it relates to > referencing symbols. > In particular in the Steven's book this is bothersome because the symbol > "err_sys" > is used all over the book. See below: > > My Library path is defined as: > chi# echo $LD_LIBRARY_PATH > /usr/java/jre/lib:/usr/lib:/usr/local/lib:/usr/local/X11/lib:/usr/dt/lib:/usr/openwin/lib:/ora0 > /app/oracle/product/8.1.7/lib:/app/netscape/server4/bin/https/jre/lib:/app/netscape/se > rver4/bin/https/jre/lib/sparc:/app/netscape/server4/bin/https/jre/lib/sparc/classic:/app/ > netscape/server4/bin/https/jre/lib/sparc/native_threads > > Steven's Advanced UNIX programming: > Compiling his first couple of examples generates exceptions on err_sys > see ld > output below: > > ############# > # 1.1 /apue/file/ls1.c > ############# > Undefined first referenced > symbol in file > err_sys /var/tmp/ccfUg64S.o > ld: fatal: Symbol referencing errors. No output written to a.out > collect2: ld returned 1 exit status > ############## > > It looks like err_sys is defined is the "ourhdr.h" file included in the > local directory. > ############## > # from ourhdr.h > ############## > void err_sys(const char *, ...); > > > ############### > On O'Reilly's UNIX Systems Programming for SVR4. Chapter 2 examples and > > others ld errors out with what appears to be the implementation of > <string.h>? Or > soemthing else... see ld output: > > ################ > # /examples/ch02/solaris/translate.c > ################ > chi# gcc translate.c > Undefined first referenced > symbol in file > outputLine /var/tmp/cckB6GJm.o > inputLine /var/tmp/cckB6GJm.o > strtrns /var/tmp/cckB6GJm.o > ld: fatal: Symbol referencing errors. No output written to a.out > > It seems like "strtrns" is defined on "libgen.h" > > chi# grep strtrns /usr/include/libgen.h > extern char * strtrns(const char *, const char *, const char *, char > *); > extern char * strtrns(); > > As a matter of fact, On The Oreilly book, all the programs under > /examples/ch02/common/*.c fail with ld errors: > > /examples/ch02/common > bsort-alpha.c, bsort-length.c, bsort-malloc.c, caseconv.c, iosubs.c, > make-a-list.c, > markline.c, mkstemp.c, parse-cmdline.c, search-char.c, search-charset.c, > > search-string.c, and search-token.c > > bsort-alpha.c > Undefined first referenced > symbol in file > outputLine /var/tmp/ccAXboD5.o > inputLine /var/tmp/ccAXboD5.o > ld: fatal: Symbol referencing errors. No output written to > bsort-alpha.c.out > collect2: ld returned 1 exit status > > > bsort-length.c > Undefined first referenced > symbol in file > outputLine /var/tmp/cc3cEjOp.o > inputLine /var/tmp/cc3cEjOp.o > ld: fatal: Symbol referencing errors. No output written to > bsort-length.c.out > collect2: ld returned 1 exit status > > bsort-malloc.c > Undefined first referenced > symbol in file > outputLine /var/tmp/cce3QmuY.o > inputLine /var/tmp/cce3QmuY.o > ld: fatal: Symbol referencing errors. No output written to > bsort-malloc.c.out > collect2: ld returned 1 exit status > > caseconv.c > Undefined first referenced > symbol in file > outputChar /var/tmp/cckuuJeY.o > inputChar /var/tmp/cckuuJeY.o > ld: fatal: Symbol referencing errors. No output written to > caseconv.c.out > collect2: ld returned 1 exit status > > etc > > The code is directly from the books for web-sites for the books. Any > ideas as to > why these do not compile? > > Carlos Sevillano > > ________________________________________________ > Get your own "800" number > Voicemail, fax, email, and a lot more > http://www.ureach.com/reg/tag > > ________________________________________________ Get your own "800" number Voicemail, fax, email, and a lot more http://www.ureach.com/reg/tag _______________________________________________ sunmanagers mailing list sunmanagers@sunmanagers.org http://www.sunmanagers.org/mailman/listinfo/sunmanagersReceived on Fri Feb 22 13:27:23 2002
This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:34 EST