CMake: add a static library to the shared lib library

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

For example, if it should contain my file file1.o, file2.o, then libfoo.la is statically linked and then written to disk as a .so file that is dynamically linked to libbar.so

Is it possible?

+4
source share
1 answer

You can link a static library to a shared library. On most Unix, you'll need to add the -fPIC flag or its equivalent to create position-independent code when creating a static library. There is no PIC on Windows, i.e. Binding static to common just works out of the box.

+1
source

Source: https://habr.com/ru/post/1305528/


All Articles