LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Archiving static libraries: "could not read symbols" (https://www.linuxquestions.org/questions/linux-newbie-8/archiving-static-libraries-could-not-read-symbols-730871/)

Manidas 06-05-2009 04:54 AM

Archiving static libraries: "could not read symbols"
 
Hi All,
I have two static libraries, and i need to create a single library by combining these two
i.e I have libone.a and libtwo.a and need to make libcombined.a by combining libone.a and libtwo.a

I tried
ar -rs libcombined.a libone.a libtwo.a
But when i tried to link this library to an exe i got the error

"libcombined.a:could not read symbols: Archive has no index; run ranlib to add one"

I tried running ranlib, but still i am getting this error , please help.

colucix 06-05-2009 02:47 PM

Try to extract all the objects from libone.a and libtwo.a then merge them all together:
Code:

$ ar -x libone.a
$ ar -x libtwo.a
$ ar -r -c libcombined.a *.o

this should recreate the index. Anyway, from the man page of ar:
Quote:

The ordering of members in an archive can make a difference in how programs are linked using the library, if a symbol is defined in more than one member.
this may bring to complications.


All times are GMT -5. The time now is 07:35 PM.