克隆 jetbot_ros 后,catkin 编译后出现 Build jetbot_ros fails for: /usr/bin/ld: cannot find -lnvbuf_utils
尝试完成 jetbot_ros 的构建和安装过程,但它在“构建 jetbot_ros”阶段失败,并出现以下构建错误:
查看库文件 libnvbuf_utils 是否已安装在系统上。
ls -la /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so
lrwxrwxrwx 1 root root 23 Jan 15 2021 /usr/lib/aarch64-linux-gnu/tegra/libnvbuf_utils.so -> libnvbuf_utils.so.1.0.0
看到的错误:
`jetbot@nano-4gb-jp45:~/workspace/catkin_ws$ catkin_make
基本路径:/home/jetbot/workspace/catkin_ws
源空间:/home/jetbot/workspace/catkin_ws/src
构建空间:/home/jetbot /workspace/catkin_ws/build
开发空间:/home/jetbot/workspace/catkin_ws/devel
安装空间:/home/jetbot/workspace/catkin_ws/install
运行命令:“/home/jetbot/workspace/catkin_ws/build”中的“make cmake_check_build_system”
-- 使用 CATKIN_DEVEL_PREFIX: /home/jetbot/workspace/catkin_ws/devel
-- 使用 CMAKE_PREFIX_PATH: /home/jetbot/workspace/catkin_ws/devel;/opt/ros/melodic
-- 此工作区覆盖:/home/jetbot/workspace/ catkin_ws/devel;/opt/ros/melodic
-- 找到 PythonInterp: /usr/bin/python2 (找到合适的版本 "2.7.17", 最低要求是 "2")
-- 使用 PYTHON_EXECUTABLE: /usr/bin/python2
- - 使用 Debian Python 包布局
-- 使用 empy: /usr/bin/empy
-- 使用 CATKIN_ENABLE_TESTING: ON
-- 调用 enable_testing()
-- 使用 CATKIN_TEST_RESULTS_DIR: /home/jetbot/workspace/catkin_ws/build/test_results
-- 找到 gtest '/usr/src/googletest' 下的来源:gtests 将被构建
-- 在 '/usr/src/googletest' 下找到 gmock 源:gmock 将被构建
-- 找到 PythonInterp:/usr/bin/python2(找到版本“2.7.17”)
-- 使用 Python 鼻子测试:/usr/bin/ nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS 开启
-- BUILD_SHARED_LIBS 开启
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
-- ~~ 按照拓扑顺序遍历2个包:
-- ~~ - jetbot_ros
-- ~~ - ros_deep_learning
-- ~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++处理catkin package: 'jetbot_ros'
-- ==> add_subdirectory(jetbot_ros)
-- +++ 处理 catkin package: 'ros_deep_learning'
-- ==> add_subdirectory(ros_deep_learning)
检测到 ROS_DISTRO=ROS_MELODIC
检测到 ROS1 (catkin_make)
-- 配置完成
-- 生成完成
-- 构建文件已写入:/home/jetbot/workspace/catkin_ws/build
运行命令:“/home/jetbot/workspace/catkin_ws/build”中的“make -j2 -l2”
[ 3%] 链接 CXX 可执行文件 /home/jetbot/workspace/catkin_ws/devel/lib/ros_deep_learning/segnet
[ 7%] 链接 CXX 可执行文件 /home/jetbot/workspace/catkin_ws/devel/lib/jetbot_ros/jetbot_camera
/usr/bin /ld:找不到-lnvbuf_utils
collect2:错误:ld返回1退出状态
jetbot_ros/CMakeFiles/jetbot_camera.dir/build.make:168:目标'/home/jetbot/workspace/catkin_ws/devel/lib/jetbot_ros/jetbot_camera的配方' 失败
[2]: *** [/home/jetbot/workspace/catkin_ws/devel/lib/jetbot_ros/jetbot_camera] 错误 1
CMakeFiles/Makefile2:615: 目标 'jetbot_ros/CMakeFiles/jetbot_camera.dir/all' 的配方失败
make[1]: *** [jetbot_ros/CMakeFiles/jetbot_camera.dir/all] 错误 2
make[1]: *** 等待未完成的工作....
[ 18%] 构建目标 segnet
Makefile:140: 目标“所有”的配方失败
make: *** [all] 错误 2
调用“make -j2 -l2”失败
`
尝试link_directories(/usr/lib/aarch64-linux-gnu/tegra)
在 CMakeLists.txt 中添加此行
在 include_directories 行上方添加 link_directories 解决了这个问题。