From mboxrd@z Thu Jan 1 00:00:00 1970 From: stuarts@icpdd.neca.nec.com.au (Stuart Summerville) To: help-gcc@gnu.org Subject: Need help building & integrating library into target program Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <3850aaaa.25683279@news.mul.nec.com.au> X-SW-Source: 1999-12n/msg00143.html Message-ID: <19991231222400.-GXU6fxTTcO9yxcPJ_bcXzO0PHMfJ0v59IKL7qlR_wo@z> Hi all, I'm trying to build a custom library that is then integrated into other target programs. I'm having problems linking the library into the final executable. Here's the steps I've taken: 1) Compile to object file (using -c switch on gcc) each of the source files for the library. 2) Archive the object files together in mylib.a. This is using 'ar rv mylib.a *.o'. 3) Compile another source file (new_app.c) ready to use the library. Same compilation as before, to an object file. 4) Link new_app.o with mylib.a, using gcc. I've tried passing in the -static switch also. The output is new_app, which should also contains any required functions from mylib. All goes well until runtime, when ld.so.1 informs me that it couldn't open mylib.o (as opposed to mylib.a) & that new_app has been killed. Why is this happening? Where is it getting mylib.o from? Another makefile I have aquired, that I've based my makefile on, takes one extra step after creating mylib.a. It runs the following: prompt> : mylib.a This seems to fuction properly,and does change the file, somehow. The variable used to hold this ':' keyword is called $(RANLIB) which suggests its generating an index into mylib.a, but I'm not sure how this mapping (of ':' to ranlib or 'ar -s') is done, unless its prodding the make program to do so, somehow. So far as I can tell, my makefile is manipulating the library file just as the sample one is. If necessary, can you suggest some methods of analysing mylib.a to look for problems? Thanks for any help, sTu. ________________________________________________________________________ Stuart Summerville NEC Australia Pty. Ltd. ph: (+61 3) 9264-3090 Integrated Comm Products (R&D) fax:(+61 3) 9264-3841 649-655 Springvale Road Mulgrave stuarts@icpdd.neca.nec.com.au VIC 3170, AUSTRALIA