4

So I have, say, libA.a libB.a libC.a libD.so and some code that is linked into libPack.a. Later on, I'll create libFinal.so that will link to libPack.a and the libFinal.so is finally used on a executable.

When the linker creates the static library, I believe every dynamic library is resolved and included at compile time within the static library. Does it do that as well for (-fPIC) third party static libraries?

How can I combine a bunch of static libraries and shared libraries into one huge stand-alone libFinal.so library using CMake? If that's not possible, does it mean I have to provide all the lib dependences to the client?

I've managed to get the executable working with a dummy library without dependencies (without libA...D), but I get undefined symbols for third-party libraries when I use a libPack.a linked to libA..D. My guess is that static libraries are not shipped within libPack.a, but I'm not sure what's going on.

quimnuss
  • 1,503
  • 2
  • 17
  • 37
  • A static library is not linked, think of it as a `zip` of object files. Linking only occurs on executables and shared libraries. – Steve-o Apr 10 '13 at 17:44
  • what i think is the *undefined symbol* is from `libD.so` or other 3rd party library on your system – bikram990 May 09 '13 at 12:07

1 Answers1

0

Following answers might be useful: How to combine several C/C++ libraries into one? and Merge multiple .so shared libraries

If this meets your needs, you could configure the CMake script to add to the project a pre-link event that combines the libraries into libFinal.so and furhter link libFinal.so to the executable.

Community
  • 1
  • 1