draco icon indicating copy to clipboard operation
draco copied to clipboard

GCC/clang: Draco shared library requires -fvisibility=default but does not set it

Open RichardTea opened this issue 5 years ago • 2 comments

This causes linking to fail when included in a master project that sets -fvisibility=hidden

Draco does set the equivalent flag for MSVC

RichardTea avatar Jan 28 '21 10:01 RichardTea

Thanks for the report.

Is the master project manipulating CMAKE_CXX_FLAGS and/or CMAKE_EXE_LINKER_FLAGS? Projects doing so impact the child projects loaded via CMake.

You can add the following args at configure time to control Draco visibility (aka the CMake command line):

  • -DDRACO_CXX_FLAGS=-fvisibility=default
  • -DDRACO_EXE_LINKER_FLAGS=-fvisibility=default

edit: s/hidden/default/ and added question about CMAKE_<TOOL>_FLAGS.

tomfinegan avatar Jan 28 '21 19:01 tomfinegan

Most so/dylib projects set -fvisibility=hidden, as it is common to only want to export a small subset of symbols in a dynamic library and hiding the unnecessary ones greatly improves library loading times.

This means many dynamic library projects that also require draco have set the visibility flag further up the cmakelists. Probably they shouldn't do that, but it would be helpful if draco explicitly set the flags it requires.

RichardTea avatar May 21 '21 11:05 RichardTea