Search code examples
linuxgccg++unix-arobject-files

Include static lib in shared object?


I would like to compile a bunch of static libs into a shared object. So far I have

g++ -Wl -shared -fPIC -o myshared.so objs/*.o

Where the objs/*.o above contains all the object files extracted from the various static libs using ar.

UPDATE: basically, I'm wondering if I might be able to use the .a files directly on the command line without having to extract them.


Solution

  • This really is a 2 step process:

    ar -x mylib.a
    gcc -shared *.o -o mylib.so