ElektraInitiative / libelektra

Elektra serves as a universal and secure framework to access configuration settings in a global, hierarchical key database.
https://www.libelektra.org
BSD 3-Clause "New" or "Revised" License
208 stars 123 forks source link

missing pthread linking #683

Closed sl1pkn07 closed 7 years ago

sl1pkn07 commented 8 years ago
[ 55%] Linking CXX executable ../../../bin/testmod_type
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::UnitTestImpl::~UnitTestImpl()':
gtest-all.cc:(.text+0xd21a): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text+0xd234): undefined reference to `pthread_key_delete'
gtest-all.cc:(.text+0xd42a): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text+0xd444): undefined reference to `pthread_key_delete'
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::UnitTestImpl::UnitTestImpl(testing::UnitTest*)':
gtest-all.cc:(.text+0xe5a0): undefined reference to `pthread_key_create'
gtest-all.cc:(.text+0xe790): undefined reference to `pthread_key_create'
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::~ThreadLocal()':
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED5Ev]+0x1b): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED2Ev[_ZN7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEED5Ev]+0x30): undefined reference to `pthread_key_delete'
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::TraceInfo> > >::~ThreadLocal()':
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED5Ev]+0x1e): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text._ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED2Ev[_ZN7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEED5Ev]+0x35): undefined reference to `pthread_key_delete'
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<std::vector<testing::internal::TraceInfo, std::allocator<testing::internal::TraceInfo> > >::GetOrCreateValue() const':
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv]+0x24): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalISt6vectorINS0_9TraceInfoESaIS3_EEE16GetOrCreateValueEv]+0x146): undefined reference to `pthread_setspecific'
../../../lib/libgtest.a(gtest-all.cc.o): In function `testing::internal::ThreadLocal<testing::TestPartResultReporterInterface*>::GetOrCreateValue() const':
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv]+0x1c): undefined reference to `pthread_getspecific'
gtest-all.cc:(.text._ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_31TestPartResultReporterInterfaceEE16GetOrCreateValueEv]+0x73): undefined reference to `pthread_setspecific'
collect2: error: ld returned 1 exit status
src/plugins/type/CMakeFiles/testmod_type.dir/build.make:124: recipe for target 'bin/testmod_type' failed
make[2]: *** [bin/testmod_type] Error 1
CMakeFiles/Makefile2:10100: recipe for target 'src/plugins/type/CMakeFiles/testmod_type.dir/all' failed
make[1]: *** [src/plugins/type/CMakeFiles/testmod_type.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

19b3225

markus2330 commented 8 years ago

Thanks for reporting. The thread linkage for type was removed for #432 in f0e71ed36654032811496172a93b14655fdc45a5, but it is now added globally: every add_gtest now links against CMAKE_THREAD_LIBS_INIT.

Did you get some cmake warning that the Threads library was not found?

At which version of Arch Linux do you get this error? @KurtMi or @sirblackheart can you reproduce it?

sl1pkn07 commented 8 years ago
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAS_CXX_STD
-- Performing Test HAS_CXX_STD - Success
-- Performing Test LD_ACCEPTS_VERSION_SCRIPT
-- Performing Test LD_ACCEPTS_VERSION_SCRIPT - Success
-- GCC detected
-- Performing Test HAS_CFLAG_MAYBE_UNINITIALIZED
-- Performing Test HAS_CFLAG_MAYBE_UNINITIALIZED - Success
-- C flags are -march=native -O2 -pipe -fstack-protector-strong  -std=gnu99  -Wno-deprecated-declarations  -Wno-long-long -pedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized -Wsign-compare -Wfloat-equal -Wformat-security
-- CXX flags are -march=native -O2 -pipe -fstack-protector-strong  -std=c++11  -Wno-deprecated-declarations  -Wold-style-cast -Wstrict-null-sentinel -D_GLIBCXX_USE_NANOSLEEP -Wno-missing-field-initializers -Woverloaded-virtual  -Wsign-promo  -Wno-long-long -pedantic -Wno-variadic-macros -Wall -Wextra -Wno-overlength-strings -Wsign-compare -Wfloat-equal -Wformat-security -Wshadow -Wcomments -Wtrigraphs -Wundef -Wuninitialized -Winit-self -Wmaybe-uninitialized
-- Detected Archrolling-x86_64. Use make package to build packages (TBZ2).
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.11") 
-- Found Perl: /usr/bin/perl (found version "5.22.1") 
-- Looking for __GNU_LIBRARY__
-- Looking for __GNU_LIBRARY__ - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Found augeas: /usr/lib64/libaugeas.so
-- Found LibXml2: /usr/lib64/libxml2.so (found version "2.9.3") 
-- Include Plugin augeas
-- Include Plugin ccode
-- Include Plugin conditionals
-- Include Plugin constants
-- Include Plugin counter
-- Checking for one of the modules 'openssl'
-- Found libgcrypt: -lgcrypt -lgpg-error
-- Include Plugin crypto_gcrypt
-- Include Plugin crypto_openssl
-- Include Plugin csvstorage
-- Found CURL: /usr/lib64/libcurl.so (found version "7.48.0") 
-- Include Plugin curlget
-- Found D-Bus: /usr/lib64/libdbus-1.so
-- Include Plugin dbus
-- Include Plugin doc
-- Include Plugin dpkg
-- Include Plugin dump
-- Include Plugin enum
-- Include Plugin error
-- Looking for iconv
-- Looking for iconv - found
-- Found iconv library: 
-- Include Plugin filecheck
-- Include Plugin fstab
-- Include Plugin glob
-- Include Plugin hexcode
-- Include Plugin hidden
-- Include Plugin hosts
-- Include Plugin iconv
-- Include Plugin ini
-- Include Plugin iterate
-- Found JNI: /usr/lib64/jvm/java-8-jdk/jre/lib/amd64/libjawt.so  
-- Looking for JNI_VERSION_1_8
-- Looking for JNI_VERSION_1_8 - found
-- Include Plugin jni
-- Found systemd-journal: /usr/lib64/libsystemd.so
-- Include Plugin journald
-- Include Plugin keytometa
-- Include Plugin line
-- Include Plugin lineendings
-- Include Plugin list
-- Include Plugin logchange
-- Found Lua: /usr/lib64/liblua5.2.so;/usr/lib64/libm.so (found suitable version "5.2.4", minimum required is "5.1") 
-- Found SWIG: /usr/bin/swig (found suitable version "3.0.8", minimum required is "3") 
-- Include Plugin lua
-- Include Plugin mathcheck
-- Include Plugin network
-- Include Plugin ni
-- Include Plugin noresolver
-- Include Plugin null
-- Include Plugin path
-- Include Plugin profile
-- Found PythonLibs: /usr/lib64/libpython3.5m.so (found suitable version "3.5.1", minimum required is "3") 
-- Include Plugin python
CMake Deprecation Warning at src/plugins/python2/CMakeLists.txt:2 (message):
  Python 2.7 plugin has been deprecated

-- Found Python2Libs: /usr/lib64/libpython2.7.so (found suitable version "2.7.11", minimum required is "2.7") 
-- Include Plugin python2
-- Include Plugin regexstore
-- Include Plugin rename
-- Include Plugin resolver_fm_hpu_b
-- Include Plugin resolver_fm_b_b
-- Include Plugin resolver_fm_pb_b
-- Include Plugin resolver_fm_hb_b
-- Include Plugin resolver_fm_hp_b
-- Include Plugin resolver_fm_ub_x
-- Include Plugin resolver_fm_xb_x
-- Include Plugin resolver_fm_xp_x
-- Include Plugin resolver_fm_xhp_x
-- Include Plugin resolver_fm_uhb_xb
-- Include Plugin semlock
-- Include Plugin shell
-- Include Plugin simpleini
-- Include Plugin spec
-- Include Plugin struct
-- Include Plugin sync
-- Include Plugin syslog
-- Boost version: 1.60.0
-- Include Plugin tcl
-- Include Plugin template
-- Include Plugin timeofday
-- Include Plugin tracer
-- Include Plugin type
-- Include Plugin uname
-- Include Plugin validation
-- Include Plugin wresolver
-- Include Plugin xmltool
-- Found Yajl: /usr/lib64/libyajl.so  
-- Include Plugin yajl
-- Include Binding cpp
-- Include Binding jna
-- Found Java: /usr/lib/jvm/java-8-jdk/bin/java (found version "1.8.0.92") 
-- Include Binding swig
-- Found Python2Interp: /usr/bin/python2.7 (found suitable version "2.7.11", minimum required is "2.7") 
-- Include Binding swig_python2
CMake Deprecation Warning at src/bindings/swig/python2/CMakeLists.txt:16 (message):
  Python 2 bindings has been deprecated

-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.1", minimum required is "3") 
-- Include Binding swig_python
-- Include Binding swig_lua
-- Checking for module 'gobject-2.0>=2.36'
--   Found gobject-2.0, version 2.48.0
-- Include Binding glib
-- Checking for module 'gobject-introspection-1.0>=1.38'
--   Found gobject-introspection-1.0, version 1.48.0
-- Include Binding gi_python
-- Include Binding gi_lua
-- Include Tool kdb
-- Include Tool gen
-- Include Tool race
-- Found LibRt: /usr/lib64/librt.so  
-- Include Tool qt-gui
-- Looking for clearenv
-- Looking for clearenv - found
-- Looking for setenv
-- Looking for setenv - found
-- Looking for futimens
-- Looking for futimens - found
-- Looking for futimes
-- Looking for futimes - found
-- Looking for glob
-- Looking for glob - found
-- Looking for clock_gettime
-- Looking for clock_gettime - found
-- Looking for ctype.h
-- Looking for ctype.h - found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for locale.h
-- Looking for locale.h - found
-- Looking for stdio.h
-- Looking for stdio.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for time.h
-- Looking for time.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of int
-- Check size of int - done
-- Check size of long
-- Check size of long - done
-- Check size of long long
-- Check size of long long - done
-- Check size of long double
-- Check size of long double - done
-- Check size of mode_t
-- Check size of mode_t - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/makepkg/elektra-git/src/build
rautesamtr commented 8 years ago

Yes, i could reproduce this with @sl1pkn07 s PKGBUILD. Removing -DBUILD_FULL=OFF seems to fix this.

markus2330 commented 8 years ago

Yes, thats a good tipp. Currently running tests is only fully supported with -DBUILD_FULL=OFF otherwise many testmod* unit tests do not build at all.

The question is why the thread library is not linked correctly, even though cmake/Modules/LibAddTest.cmake has target_link_libraries(${source} ${CMAKE_THREAD_LIBS_INIT}). make VERBOSE=1 tells you what the linker does. Maybe the -pthread needs to be shuffled at a different place?

markus2330 commented 7 years ago

This issue is quite old and these parts have changed quite a bit. Please reopen if you can still reproduce the problem.