From 3238c41ea5c390c22766aa09c558c3ea3837dec4 Mon Sep 17 00:00:00 2001 From: Ian Reinhart Geiser Date: Sat, 5 Jun 2021 19:17:51 -0400 Subject: [PATCH] Fix compile on debian buster On debian buster with gcc 8.3 I see the following compiler error: ``` [build] FAILED: 3rdparty/eventbus/use_case/basic/UseCase_Basic [build] : && /bin/g++-8 -DTORRENT_NO_DEPRECATE=1 -DSPDLOG_FMT_EXTERNAL=1 -DJSONCONS_HAS_OPTIONAL=1 -DNO_BOOST_SERIALIZATION=1 -DGSL_THROW_ON_CONTRACT_VIOLATION -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -g 3rdparty/eventbus/use_case/basic/CMakeFiles/UseCase_Basic.dir/src/main.cpp.o -o 3rdparty/eventbus/use_case/basic/UseCase_Basic 3rdparty/eventbus/lib/libEventBus.a && : [build] /usr/bin/ld: 3rdparty/eventbus/use_case/basic/CMakeFiles/UseCase_Basic.dir/src/main.cpp.o: in function `std::__shared_mutex_pthread::lock()': [build] /usr/include/c++/8/shared_mutex:103: undefined reference to `pthread_rwlock_wrlock' [build] /usr/bin/ld: 3rdparty/eventbus/use_case/basic/CMakeFiles/UseCase_Basic.dir/src/main.cpp.o: in function `std::__shared_mutex_pthread::unlock()': [build] /usr/include/c++/8/shared_mutex:123: undefined reference to `pthread_rwlock_unlock' [build] /usr/bin/ld: 3rdparty/eventbus/lib/libEventBus.a(EventBus.cpp.o): in function `std::__shared_mutex_pthread::lock_shared()': [build] /usr/include/c++/8/shared_mutex:139: undefined reference to `pthread_rwlock_rdlock' [build] collect2: error: ld returned 1 exit status ``` This adds threads to the linker arguments. --- lib/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 045c881..d01f97a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -10,7 +10,7 @@ project(EventBus ) # Dependencies -# No dependencies for EventBus yay! +find_package(Threads) # Introduce variables: # * CMAKE_INSTALL_LIBDIR @@ -19,7 +19,6 @@ project(EventBus include(GNUInstallDirs) include(cmake/InstallHelp.cmake) - # Layout. This works for all platforms: # * /lib*/cmake/ # * /lib*/ @@ -71,6 +70,7 @@ target_include_directories(EventBus PUBLIC $ $ ) +target_link_libraries(EventBus ${CMAKE_THREAD_LIBS_INIT}) # Add definitions for targets # Values: