系统:Ubuntu18.04
CUDA:11.3
在编译项目时出现报错:/usr/bin/ld: cannot find -lcudart
/usr/bin/ld: cannot find -lcudart
collect2: error: ld returned 1 exit status
CMakeFiles/ORB_SLAM2.dir/build.make:625: recipe for target '../lib/libORB_SLAM2.so' failed
make[2]: *** [../lib/libORB_SLAM2.so] Error 1
CMakeFiles/Makefile2:252: recipe for target 'CMakeFiles/ORB_SLAM2.dir/all' failed
make[1]: *** [CMakeFiles/ORB_SLAM2.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
看来是无法链接到cudart库,使用find命令在根目录查找该库的位置
cd /
sudo find . -name "libcudart.so"
查找到该库的位置在如下地方:
./usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudart.so
使用软连接将该库添加在/usr/lib/目录下,命令如下
ln -s /usr/local/cuda-11.3/targets/x86_64-linux/lib/libcudart.so /usr/lib/libcudart.so
随后再重新编译,该问题解决。