boost-cmake icon indicating copy to clipboard operation
boost-cmake copied to clipboard

Add option to support building boost dynamic library

Open Char-Aznable opened this issue 6 years ago • 6 comments

I have a usage case where I need to link my app against Boost::unit_test_framework dynamic library with BOOST_TEST_DYN_LINK defined. It seems boost-cmake only builds boost static libraries which causes the error in my use case:

ld: CMakeFiles/mytest.dir/test.cpp.o: in function `main':
test.cpp:(.text+0xad3): undefined reference to `boost::unit_test::unit_test_main(bool (*)(), int, char**)'

I suggest boost-cmake should have an option to allow the users to use either dynamic or static boost libraries

Char-Aznable avatar May 31 '19 21:05 Char-Aznable

Here's the documentation of boost.Test dynamic library usage: https://www.boost.org/doc/libs/1_70_0/libs/test/doc/html/boost_test/adv_scenarios/shared_lib_customizations.html

Char-Aznable avatar May 31 '19 22:05 Char-Aznable

Dynamic libraries can cause a lot of issues. Why isn't it acceptable for you to link against the static version?

Orphis avatar Jun 01 '19 00:06 Orphis

Huge project, complicated dependency, not an option

Char-Aznable avatar Jun 01 '19 07:06 Char-Aznable

It shouldn't be complicated to fix it to accept static libraries there though if you really want to use those build scripts.

But if you insist on going with the dynamic libraries route, it's very unlikely to be ever supported here and you should probably use the official Boost distribution instead and maybe try their own new CMake build files.

Orphis avatar Jun 01 '19 13:06 Orphis

No, it's rather labor intensive. The Boost.Test entry point is different for dynamic vs static lib, which means that I have manually change thousands of lines of code written by different people with tons of macros all over the place.

Just curious, what is the trouble for supported dynamic lib?

Char-Aznable avatar Jun 01 '19 16:06 Char-Aznable

It can be automated with CMake and some other tooling too. Supporting dynamic builds means I'd have to double the test coverage and add it for each library.

In general, there are issues with using shared libraries on all platforms, so it's always safer to use static builds.

Orphis avatar Jun 01 '19 23:06 Orphis