c++ - Compilation of OpenCV using CMakeList under ROS -


i trying compile opencv code using cmakelist.txt (under ros (robot operating system)), cmakelist working, because on pc working well. installed opencv , in opencv examples directory compiled examples using g++ , flags, compilation successful. when want compile other code using cmakelist, error:

cmakefiles/aupark_node.dir/src/wrapper.cpp.o: in function `wrapper::set_head_image(std::string)': wrapper.cpp:(.text+0x2ef1): undefined reference `cv::imread(cv::string const&, int)' 

in wrapper.cpp had appropriate includes.

#include <opencv2/opencv.hpp> #include <image_transport/image_transport.h> #include <cv_bridge/cv_bridge.h> #include <sensor_msgs/image_encodings.h> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/highgui/highgui.hpp> 

and cmakelist.txt here:

cmake_minimum_required(version 2.8.3) project(aupark)  set(cmake_cxx_flags "-std=c++11 ${cmake_cxx_flags}") find_package(catkin required components cmake_modules roscpp gencpp moveit_ros_planning_interface moveit_msgs cv_bridge) find_package(eigen required) include_directories(${eigen_include_dirs}) add_definitions(${eigen_definitions})  catkin_package()  add_executable(aupark_node src/aupark_node.cpp src/wrapper.cpp src/wrapper.h) target_link_libraries(aupark_node ${catkin_libraries}) 

what can wrong?

output of pkg-config opencv --libs:

-l/usr/local/lib -lopencv_shape  -lopencv_stitching  -lopencv_objdetect  -lopencv_superres   -lopencv_videostab  -lopencv_calib3d  -lopencv_features2d   -lopencv_highgui  -lopencv_videoio  -lopencv_imgcodecs  -lopencv_video  -lopencv_photo  -lopencv_ml  -lopencv_imgproc  -lopencv_flann  -lopencv_viz  -lopencv_core  -lopencv_hal  

you not linking against opencv in cmakelists.txt.

to add find_package(opencv required) @ top , link target against it:

target_link_libraries(aupark_node ${catkin_libraries} ${opencv_libs}) 

a minimal example on how use opencv cmake can found in the opencv documentation.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -