遇到报错:
--- stderr: data_preprocessor
CMakeFiles/get_Depth.dir/nodes/get_Depth/get_Depth.cpp.o: In function `SaveDepth::create_depth()':
get_Depth.cpp:(.text+0x9c8): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0xa8b): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0xb30): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0xb8c): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0xbff): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0xd23): undefined reference to `cv::Mat::Mat(int, int, int)'
CMakeFiles/get_Depth.dir/nodes/get_Depth/get_Depth.cpp.o: In function `SaveDepth::read_CalibFile()':
get_Depth.cpp:(.text+0x248e): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0x24c2): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text+0x24f6): undefined reference to `cv::Mat::Mat()'
CMakeFiles/get_Depth.dir/nodes/get_Depth/get_Depth.cpp.o: In function `main':
get_Depth.cpp:(.text.startup+0xacf): undefined reference to `cv::Mat::Mat()'
get_Depth.cpp:(.text.startup+0xb00): undefined reference to `cv::Mat::Mat()'
CMakeFiles/get_Depth.dir/nodes/get_Depth/get_Depth.cpp.o:get_Depth.cpp:(.text.startup+0xb0d): more undefined references to `cv::Mat::Mat()' follow
collect2: error: ld returned 1 exit status
make[2]: *** [devel/lib/data_preprocessor/get_Depth] Error 1
make[1]: *** [CMakeFiles/get_Depth.dir/all] Error 2
make: *** [all] Error 2
解决方法:
找到data_preprocessor功能包的的Cmakelist.txt文件,进行如下修改:
//指定OpenCV,此处为你安装的版本
find_package(OpenCV 3.4 REQUIRED)
include_directories(
${catkin_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
target_link_libraries(get_Depth ${catkin_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(get_PCD ${catkin_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(get_Image ${catkin_LIBRARIES} ${OpenCV_LIBS})
如图所示:
问题解决