Jetson Orin AGX上的CUDA开发报错:/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): undefined reference to symbol ‘pthread_rwlock_wrlock@@GLIBC_2.17’
环境
- 设备:Jetson Orin AGX
- Model:Jetson AGX Orin - Jetpack 5.1.1 [L4T 35.3.1]
- Distribution: Ubuntu 20.04 focal
- Release: 5.10.104-tegra
- CUDA: 11.4.315
- cuDNN: 8.6.0.166
- TensorRT: 8.5.2
- VPI: 2.2.7
- Vulkan: 1.3.204
- OpenCV: 4.5.4 - with CUDA: NO
报错内容
[ 64%] Linking CXX executable modnet_test
/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): undefined reference to symbol ‘pthread_rwlock_wrlock@@GLIBC_2.17’
/usr/bin/ld: /usr/lib/aarch64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
解决办法
在你的cmakelist.txt 中为你的某个可执行对象使用target_link_libraries为其链接pthread库
如果你有多个target_link_libraries函数,有多个可执行对象,且你不能确定要为哪一个链接,那就全链接上。
更改前
target_link_libraries(utils PUBLIC ${OpenCV_LIBS} )
更改后
target_link_libraries(utils PUBLIC ${OpenCV_LIBS} pthread)
原因分析
就是没链接到pthread库