wpb_home
wpb_home copied to clipboard
wpb_home_behaviors 和 wpb_home_tutorials 功能包的 OpenCV 链接问题
我在 Jetson 上编译 wpb_home_behaviors 功能包时,出现了编译错误。
从错误日志可以看出,wpb_home_behaviors 和 wpb_home_tutorials 功能包的 OpenCV 链接出现了问题,特别是以下文件中:
wpb_home_behaviors/src/wpb_home_face_detect_3d.cpp
wpb_home_behaviors/src/wpb_home_objects_3d.cpp
wpb_home_behaviors/src/wpb_home_grab_server.cpp
wpb_home_tutorials/src/wpb_home_face_detect.cpp
wpb_home_tutorials/src/wpb_home_obj_detect.cpp
这些文件都涉及到 OpenCV 的 cv::Mat 类,而链接器未能找到 cv::Mat::Mat() 的实现,说明在这些文件中 OpenCV 并未正确链接。
因此,需要将 OpenCV 库显式地链接到使用 OpenCV 的可执行文件,需要对 CMakeLists.txt 文件进行如下修改:
wpb_home_behaviors/CMakeLists.txt
target_link_libraries(wpb_home_grab_server
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(wpb_home_pass_server
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(wpb_home_objects_3d
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(wpb_home_grab_action
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(wpb_home_face_detect_3d
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
target_link_libraries(wpb_home_place_action
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
wpb_home_behaviors/CMakeLists.txt
target_link_libraries(wpb_home_face_detect
${catkin_LIBRARIES}
${OpenCV_LIBS}
)
target_link_libraries(wpb_home_obj_detect
${catkin_LIBRARIES}
${OpenCV_LIBS}
)