Search code examples
boost

Boost 1.80.0 compiled libraries with -fvisibility=hidden creating issues


I'm compiling boost sources 1.80.0 to generate static libraries and by default boost uses these options :

-fvisibility-inlines-hidden -fvisibility=hidden

This caused error on run time in our shared libraries of the project with undefined symbols. After analyzing the issue we found that visibility need to be global not local.

I tried to recompile using: ./b2 --prefix=../build_local --exec-prefix=../build_local --build-type=complete variant=release link=static runtime-link=static threading=multi --layout=versioned -d+2 local-visibility=global cxxflags=-fPIC --without-python -a install

also

./b2 --prefix=../build_local --exec-prefix=../build_local --build-type=complete variant=release link=static runtime-link=static threading=multi --layout=versioned -d+2 cxxflags=-fPIC -fvisibility=default --without-python -a install

but b2 continue to build all libraries with -fvisibility-inlines-hidden -fvisibility=hidden.

Any help please on how to achieve this.

Compiler GCC 4.4.8

OS : Linux RHEL 7


Solution

  • Solved by adding cxxflags=-fvisibility=default , here complete command :

    ./b2 --prefix=../build_local --exec-prefix=../build_local --build-type=complete variant=release link=static runtime-link=static threading=multi --layout=versioned -d+2 cxxflags=-fPIC cxxflags=-fvisibility=default --without-python -a install
    

    For readability:

    ./b2                                \
        --prefix=../build_local         \
        --exec-prefix=../build_local    \
        --build-type=complete           \
          variant=release               \
          link=static                   \
          runtime-link=static           \
          threading=multi               \
        --layout=versioned              \
        -d+2                            \
          cxxflags=-fPIC                \
          cxxflags=-fvisibility=default \
        --without-python                \
        -a install
    

    -d+2 option allow us to see executed commands with all options.