Library extension .a/.so

Peter plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Tue Apr 26 22:35:49 UTC 2005


>>>> What is the difference in libraries ending with extension .a and .so.
>>>> Can one convert  from somelib.a to somelib.so?

To convert .a to .so one must extract the contents of the .a archive 
using ar and then relink these files into a .so object. Usually it is 
necessary to also link the .so object against one of the ld.so stubs 
(usually /lib/ld-linux.so.2) to make it work. This usually works 
smoothly and solves the problem (static linking) mentioned by Lennart. 
The exact options to be used vary but the .so name must be linked with 
general options like:

$(CC) -shared -Wl,-soname,libfoo.so.1 -o libfoo.so.1.0 foo.o bar.o ...

so it 'knows' its own name internally and still works if it is renamed. 
The .o files can come from dumping the contents of one or more .a files 
using ar. See also the -rpath-link DIR --whole-archive 
--export-all-symbols --out-implib --export-dynamic -larchive 
--dynamic-linker -nostdlib options (and more) in the ld manpage.

hope this helps,
Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list