Path: chuka.playstation.co.uk!news From: Toby Sargeant Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: undefined reference to Date: Mon, 28 Feb 2000 16:55:39 +1100 Organization: PlayStation Net Yaroze (SCEE) Lines: 36 Message-ID: <38BA0DDB.C6CAB1D9@fulcrum.com.au> References: <890bpa$6g2@chuka.playstation.co.uk> <89cdu6$f2c4@chuka.playstation.co.uk> NNTP-Posting-Host: redback.spyda.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.14 i686) X-Accept-Language: en Rikki Prince wrote: > > Cheers for the quick responses Toby and Rob. However, even with your help I > couldn't figure out what was going on. Bascially, it worked when I compiled > my main.c with the the function code in main.c and even when I compiled it > together with precompiled object files of the library source (ie. gcc -o > main main.c graphics.o pad.o etc) but not with the library (.a) files I had > made with ar (-r libgraph.a graphics.o) using gcc -o main > main.c -lgraph -lpad etc. > Rather than continue mucking about with that I decided on a different > method, as I seemed to be getting nowhere quickly, and the new method worked > just as well. Now I am just compiling the library source files into objects, > but naming them .lib instead of .o. Then when compiling the program, I > include the .lib files in the compilation, just as I did with the .o files, > eg gcc -o main main.c graphics.lib pad.lib etc... One thing I just thought of. You *might* need to run ranlib. SYNOPSIS ranlib [-v|-V] archive DESCRIPTION ranlib generates an index to the contents of an archive, and stores it in the archive. The index lists each symbol defined by a member of an archive that is a relocatable object file. You may use `nm -s' or `nm --print-armap' to list this in- dex. An archive with such an index speeds up linking to the li- brary, and allows routines in the library to call each other without regard to their placement in the archive. The GNU ranlib program is another form of GNU ar; running ranlib is completely equivalent to executing `ar -s'.