From fc959172533fe9b1a5059bef0fbd43ea6ba3e28a Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Mon, 19 Mar 2012 20:54:30 +0100 Subject: [PATCH] Fix for not visible pthreads function with glibc 2.15 Linking error will appear: Linking CXX executable ../../openmw /usr/bin/ld: CMakeFiles/openmw.dir/__/__/components/bsa/bsa_archive.cpp.o: undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5' /usr/bin/ld: note: 'pthread_mutexattr_settype@@GLIBC_2.2.5' is defined in DSO /lib/libpthread.so.0 so try adding it to the linker command line /lib/libpthread.so.0: could not read symbols: Invalid operation collect2: ld returned 1 exit status if we don't add explicitly pthreads library to linker flags after update glibc to version 2.15 on (Arch) Linux. Signed-off-by: Lukasz Gromanowski --- CMakeLists.txt | 5 +++++ apps/openmw/CMakeLists.txt | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08ce829f65..ab299b5491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,11 @@ endif (APPLE) # Dependencies +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +find_package (Threads) +endif() + find_package(OGRE REQUIRED) find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 6d33298dfe..4edc08ba6a 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -81,7 +81,7 @@ add_definitions(${SOUND_DEFINE}) target_link_libraries(openmw ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${OIS_LIBRARIES} ${Boost_LIBRARIES} ${OPENAL_LIBRARY} @@ -92,6 +92,11 @@ target_link_libraries(openmw MyGUIOgrePlatform ) +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) +endif() + if(APPLE) find_library(CARBON_FRAMEWORK Carbon) target_link_libraries(openmw ${CARBON_FRAMEWORK})