gpt4 book ai didi

azure - azure存储c++ sdk编译中对符号 'pthread_rwlock_wrlock@@GLIBC_2.2.5'的 undefined reference

转载 作者:行者123 更新时间:2023-12-02 23:01:59 24 4
gpt4 key购买 nike

我正在尝试在 Fedora 22 上编译 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.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_package 调用添加到您的 CMakeLists.txt 中:

find_package(Threads)

然后,将库链接到您的目标:

target_link_libraries(my_target ${CMAKE_THREAD_LIBS_INIT})

仅此而已。您可能忘记了target_link_libraries

关于azure - azure存储c++ sdk编译中对符号 'pthread_rwlock_wrlock@@GLIBC_2.2.5'的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40376818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com