title: Compilation of OpenCV using CMakeList under ROS
body: <p>I am trying to compile <strong>openCV</strong> code using <strong>CmakeList.txt</strong> (under <strong>ROS</strong> (Robot operating system)), my CmakeList is working, because on another PC it is working well. I installed OpenCV and in openCV examples directory I compiled examples using g++ and some flags, compilation was successful. But when I want to compile my other code using CmakeList, I get this <strong>error</strong>: </p>
  
  <pre><code>CMakeFiles/aupark_node.dir/src/wrapper.cpp.o: In function `Wrapper::set_head_image(std::string)':
  wrapper.cpp:(.text+0x2ef1): undefined reference to `cv::imread(cv::String const&amp;, int)'
  </code></pre>
  
  <p>in wrapper.cpp I had all appropriate includes. </p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  #include &lt;image_transport/image_transport.h&gt;
  #include &lt;cv_bridge/cv_bridge.h&gt;
  #include &lt;sensor_msgs/image_encodings.h&gt;
  #include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;opencv2/objdetect/objdetect.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  </code></pre>
  
  <p>And my CMakeList.txt is here:</p>
  
  <pre><code>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})
  </code></pre>
  
  <p>What can be wrong? </p>
  
  <p>output of pkg-config opencv --libs:</p>
  
  <pre><code>-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 
  </code></pre>