CMake: link multiple archives (static libs) into shared library
Hi,
I have the following structure in my source code: Code:
MyProject On "mylib"-level I have just ADD_SUBDIRECTORY commands, so that cmake descends into each module. Now I'd like to bundle all modules' .a files into one single shared library libmylib.so. How can I do that using cmake? The shared library shall then be used to link all executables against. Cheers Matt |
Any ideas - suggestions - anybody? :cry:
|
That's what libtool is good for.
http://www.gnu.org/software/libtool/manual/libtool.html |
No solution. Some hints.
First : Static and shared libraries are built in two different ways. An object.o static cannot be used for a shared library. ... And vice verse : A shared library lib.so renamed to lib.a will not be recognized as a static library. http://tldp.org/HOWTO/Program-Librar...libraries.html http://tldp.org/HOWTO/Program-Librar...libraries.html The principle of making "shared" with gcc : gcc -shared -Wl,-soname,your_soname -o library_name file_list library_list ... where file_list can use files.o from multiple named directories. ( Libtool may be the preferred method, see post #2.) CMAKE links, post #2 here .. http://www.linuxquestions.org/questi...bdir-942797/#2 . |
Yeah, I added something like this but I think it's kinda ugly, i.e. when using a tool like cmake:
Code:
ADD_CUSTOM_TARGET(lib1 ALL gcc -shared -o libtest.so -Wl,--whole-archive module1/libmodule1.a module2/libmodule2.a -Wl,--no-whole-archive) Unfortunately, I can't try it, as I am fixed to using version 2.8.0 at the moment. Anyone having experience with that specific option? |
Another, cleaner option is
Code:
FILE(GLOB MODULE1_SOURCES module1/*.c) |
All times are GMT -5. The time now is 12:36 PM. |