Skip to content
Advertisement

Shared library on Linux and -fPIC error

I am trying to compile a shared library in Linux using a Makefile created with Cmake, but running make I obtain the following error:

JavaScript

I provide the following command in the CMakeLists.txt in order to say that I want a shared (.so) library:

add_library(cpp-lib SHARED ${CPP_FILES})

What else do I need to specify in order to avoid the -fPIC error shown above?

Thanks a lot in advance

Advertisement

Answer

The boost libraries needs to be compiled using -fPIC: Please have a look at: How to compile static library with -fPIC from boost.python

Try to add compiler flags by cmake by in your project:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement