4
votes

I would like to create shared library with cmake, but also I need to link it to third party static libraries.

For example if it should include my own file1.o, file2.o, then statically linked libfoo.la and then be written down to disk as .so file which dynamically linked to libbar.so

Is it even possible?

1
First of all, you can use object files directly, but if you got the sources for file1.o and file1.o use them directly, This way CMake can i.e. determine which language is used (C/C++/fortran/...) Some questions: 1. Is libbar.so the shared library you want to create? 2. Is libfoo.la the third party static library? 3. Do you got the sources for file1.o and file2.o? - Maik Beckmann

1 Answers

1
votes

It is possible to link static library to shared library. On most Unixes, you will need to add -fPIC flag or its equivalent for producing position-independent code when you build static library. On Windows, there is no PIC, i.e linking static to shared just works out of the box.