how to force compilation of Boost to use -fPIC

后端 未结 2 1550
一向
一向 2020-12-15 05:44

The team on which I work produces a shared library for use in Python. This library is entirely C++ and we use Boost to expose to python. Because we cannot guarantee that o

2条回答
  •  我在风中等你
    2020-12-15 06:10

    I believe boost automatically uses -fPIC when compiling a shared library (.so file), but the below command uses -fPIC when compiling a static library (.a file) too.

    This worked for me on boost 1.46.1:

    sudo ./bjam cxxflags=-fPIC cflags=-fPIC -a ... install
    

    The ... is where you add additional flags like threading=multi or --layout=tagged, and optionally the list of projects to build (for example: --with-regex).

    Note: using both cflags and cxxflags is unnecessary, only one is needed. See comments below.

    Reference links:

    • https://cmake.org/Wiki/TubeTK/Build_Instructions#Boost_.28optional.29
    • http://lists.boost.org/boost-users/2010/07/60682.php

提交回复
热议问题