redbaron
redbaron

Reputation: 418

CMake: add static library to shared lib

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?

Upvotes: 3

Views: 2345

Answers (1)

Vladislav Vaintroub
Vladislav Vaintroub

Reputation: 5653

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.

Upvotes: 1

Related Questions