|
Boost Users : |
Subject: [Boost-users] Why I had to use-D_GLIBCXX_USE_CXX11_ABI=0 to get a Boost.Test unit test to build and run
From: Arved Sandstrom (asandstrom2_at_[hidden])
Date: 2018-08-19 00:21:51
This is in the nature of a question, I am wondering *why* I had to use the -D_GLIBCXX_USE_CXX11_ABI=0 setting.
This development is happening on Centos 7, where the system gcc/g++ is 4.8.5. So I recently built and installed gcc/g++ 8.2.0 from source, because I like Linux and prefer to try out C++17 stuff there rather than using a recent Visual Studio. That's just background.
In any case I built the Boost Test module with
./b2 cxxflags="-stdlib=libc++ -std=c++14" linkflags="-stdlib=libc++ -std=c++14"
going off suggestions I found. No evident problems there. After the install, among other things I end up with
/usr/local/lib/libboost_unit_test_framework.so
Now, I attempted to build a unit test with
g++ -std=c++14 DocumentTest.cpp ../src/Document.cpp -I../include -L/usr/local/include -DBOOST_TEST_DYN_LINK -lboost_unit_test_framework
The linker complained about an undefined reference for
boost::unit_test::ut_detail::normalize_test_case_name[abi:cxx11](boost::unit_test::basic_cstring<char const>)
Using nm -D on the shared library I see that the proper export symbol is there. abi:cxx11 seemed to offer some indication as to the problem, which is why after some experimentation I found that adding -D_GLIBCXX_USE_CXX11_ABI=0 to the unit test build command did the trick. The resulting a.out executes just fine (purely for debugging I made sure the unit test had a C++14 feature).
I thought I sort of understood the ABI change business, gcc 5.1 before and after, but I guess I don't. What do I need to do, perhaps at the stage of building a Boost shared library, to not have to use that flag?
Thanks for any wisdom.
Arved Sandstrom
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net