Stiffstream / sobjectizer

An implementation of Actor, Publish-Subscribe, and CSP models in one rather small C++ framework. With performance, quality, and stability proved by years in the production.

Home Page:https://stiffstream.com/en/products/sobjectizer.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Timers problem when Boost is also used

foxtran opened this issue · comments

Hi!

Thank you for very cool library!

I have tried to use your library with Boost, and I am confused due to the build is failed even I only add Boost library without its real using.

I started from building my application without Boost, and the build was successful, then I added boost/1.73.0 in requirements to my conanfile.txt, and builds started failing. The problem was raised on the linking stage:

CMakeFiles/SObjectizer-error.dir/src/main.cpp.o: In function `so_5::details::event_subscription_helpers::ensure_handler_can_be_used_with_mbox(so_5::details::msg_type_and_handler_pair_t const&, so_5::intrusive_ptr_t<so_5::abstract_message_box_t> const&)':
main.cpp:(.text._ZN4so_57details26event_subscription_helpers36ensure_handler_can_be_used_with_mboxERKNS0_27msg_type_and_handler_pair_tERKNS_15intrusive_ptr_tINS_22abstract_message_box_tEEE[_ZN4so_57details26event_subscription_helpers36ensure_handler_can_be_used_with_mboxERKNS0_27msg_type_and_handler_pair_tERKNS_15intrusive_ptr_tINS_22abstract_message_box_tEEE] 0xc0): undefined reference to `so_5::exception_t::raise(char const*, unsigned int, std::string const&, int)'
CMakeFiles/SObjectizer-error.dir/src/main.cpp.o: In function `Agent* so_5::details::event_subscription_helpers::get_actual_agent_pointer<Agent>(so_5::agent_t&)':
main.cpp:(.text._ZN4so_57details26event_subscription_helpers24get_actual_agent_pointerI5AgentEEPT_RNS_7agent_tE[_ZN4so_57details26event_subscription_helpers24get_actual_agent_pointerI5AgentEEPT_RNS_7agent_tE] 0xbd): undefined reference to `so_5::exception_t::raise(char const*, unsigned int, std::string const&, int)'
CMakeFiles/SObjectizer-error.dir/src/main.cpp.o: In function `so_5::message_payload_type_impl<Updater, false>::extract_payload_ptr(so_5::intrusive_ptr_t<so_5::message_t>&)':
main.cpp:(.text._ZN4so_525message_payload_type_implI7UpdaterLb0EE19extract_payload_ptrERNS_15intrusive_ptr_tINS_9message_tEEE[_ZN4so_525message_payload_type_implI7UpdaterLb0EE19extract_payload_ptrERNS_15intrusive_ptr_tINS_9message_tEEE] 0x98): undefined reference to `so_5::exception_t::raise(char const*, unsigned int, std::string const&, int)'

I have also tried to use boost/1.69.0 and boost/1.71.0, but it did not have any effects: the error messages are, and they are similar.

I created simple repository with my code where the error is: https://github.com/FulgurIgor/SObjectizer-error. It has Travis-CI build, where the error is demonstrated:

Source code: https://github.com/FulgurIgor/SObjectizer-error/blob/master/src/main.cpp

Tested systems:

  • Fedora 32, GCC 10.1, SObjectizer/5.7.1, Boost/1.73.0 (and also Boost/1.71.0 and Boost/1.69.0).
  • Ubuntu Bionic, GCC 7.4, SObjectizer/5.7.1, Boost/1.73.0

All builds use Conan and CMake.

Hi! Thanks for reporting this.
Today is too late in my country. I'll take a look tomorrow.

I suppose that the problem in the flag _GLIBCXX_USE_CXX11_ABI=0 that is added when Boost is mentioned in conanfile.txt.

If you don't use Boost then sample project is compiled with the following flags:

CXX_FLAGS =    -O2 -DNDEBUG    -std=gnu++17

CXX_DEFINES = -DSO_5_STATIC_LIB

CXX_INCLUDES = -isystem /root/.conan/data/sobjectizer/5.7.1/stiffstream/stable/package/2a30b7d6ea2202e5393ebda51c8729dd2162b9f8/include

But if Boost is added then an additional flag is added:

CXX_FLAGS =    -O2 -DNDEBUG    -D_GLIBCXX_USE_CXX11_ABI=0 -std=gnu++17

CXX_DEFINES = -DSO_5_STATIC_LIB

CXX_INCLUDES = -I/root/.conan/data/boost/1.73.0/_/_/package/91ae5bfe3845753bb397c926531b17117d20c8f9/include -I/root/.conan/data/zlib/1.2.11/_/_/package/6af9cc7cb931c5ad942174fd7838eb655717c709/include -I/root/.conan/data/bzip2/1.0.8/_/_/package/da606cf731e334010b0bf6e85a2a6f891b9f36b0/include -isystem /root/.conan/data/sobjectizer/5.7.1/stiffstream/stable/package/2a30b7d6ea2202e5393ebda51c8729dd2162b9f8/include

And I think that the presence of _GLIBCXX_USE_CXX11_ABI leads to different name mangling and because of that names of some SObjectizer's methods can't be found in the static library that was built (I suppose) without _GLIBCXX_USE_CXX11_ABI.

Unfortunately, I'm not an expert in Conan nor CMake and don't know how to fix it quickly. It needs some time for further investigation.

I don't know is it a correct way to go but if I change a line in ~/.conan/profiles/default:

- compiler.libcxx=libstdc++
+ compiler.libcxx=libstdc++11

and then perform commands:

conan install ../ --build=missing
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

then the sample program compiled and linked without an errors.

Thank you so much! Your advice is working!

If you do not want to patch ~/.conan/profiles/default, you may specify compiler.libcxx by the following flag in conan install: -s compiler.libcxx=libstdc++11. The resulting commands are:

conan install ../ --build=missing -s compiler.libcxx=libstdc++11
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release