对符号'的未定义引用;pthread_rwlock_wrlock@@GLIBC_2.2.5';在azure存储c++;sdk编译
我正在尝试在Fedora22上编译Azure存储c++SDK。我使用的是gcc版本5.1.1-1。当我使用以下命令编译测试应用程序时:对符号'的未定义引用;pthread_rwlock_wrlock@@GLIBC_2.2.5';在azure存储c++;sdk编译,azure,azure-storage,azure-storage-blobs,azure-storage-files,Azure,Azure Storage,Azure Storage Blobs,Azure Storage Files,我正在尝试在Fedora22上编译Azure存储c++SDK。我使用的是gcc版本5.1.1-1。当我使用以下命令编译测试应用程序时: $> CASABLANCA_DIR=/source/codebox/azure/cpprestsdk/ CXX=g++ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=on $> make 它会产生以下错误消息: /usr/bin/ld: CMakeFiles/azurestoragetest.
$> CASABLANCA_DIR=/source/codebox/azure/cpprestsdk/ CXX=g++ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=on
$> make
它会产生以下错误消息:
/usr/bin/ld: CMakeFiles/azurestoragetest.dir/main.cpp.o: undefined reference to symbol 'pthread_rwlock_wrlock@@GLIBC_2.2.5'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
tests/CMakeFiles/azurestoragetest.dir/build.make:879: recipe for target 'Binaries/azurestoragetest' failed
make[2]: *** [Binaries/azurestoragetest] Error 1
CMakeFiles/Makefile2:125: recipe for target 'tests/CMakeFiles/azurestoragetest.dir/all' failed
make[1]: *** [tests/CMakeFiles/azurestoragetest.dir/all] Error 2
Makefile:126: recipe for target 'all' failed
make: *** [all] Error 2
我可以在/usr/lib64目录中看到libpthread.so.0库。我还需要安装哪个库?将正确的
find\u包
调用添加到您的CMakeLists.txt
:
find_package(Threads)
然后,将库链接到目标:
target_link_libraries(my_target ${CMAKE_THREAD_LIBS_INIT})
就这些。通常(在CMake和Azure Storage SDK之外)您可能忘记了目标链接库
,此错误表示您需要链接到-lpthread
。(对于gcc,您可能需要-pthread
)