line_det.cpp:(.text+0x1299): undefined reference to 'cv::imshow(cv::String const&, cv::_InputArray const&)' line_det.

/usr/bin/ld: warning: libmysqlclient.so.20, needed by //usr/lib/libgdal.so.20, not found (try using -rpath or -rpath-link)
CMakeFiles/line.dir/src/ line_det.cpp.o: In function 'imageCallback(boost::shared_ptr<sensor_msgs::Image_<std::allocator > const> const&)':
line_det.cpp:(.text+0x1299): to 'cv::imshow (cv::String const&, cv::_InputArray const&)' undefined reference
line_det.cpp:(.text+0x12c1): undefined reference to 'cv::waitKey(int)'
CMakeFiles/line.dir/src /line_det.cpp.o: in function 'main':
line_det.cpp:(.text+0x19c2): undefined reference to 'cv::namedWindow(cv::String const&, int)'
line_det.cpp:( .text+0x1a00): undefined reference to 'cv::resizeWindow(cv::String const&, int, int)'

insert image description here
Open the CMakeLists.txt file of the function package and add the opencv library to the file:

find_package(OpenCV REQUIRED)

insert image description here
Then also add the opencv library when generating the node:

target_link_libraries(xxxx ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})

insert image description here
Recompile the project and you're done!

Guess you like

Origin blog.csdn.net/qq_42257666/article/details/123258264
CV