0
$\begingroup$

Rosanswers logo

Hi! I'm trying to compile a ROS package in Ubuntu 12.04 64bit which has been used in Fuerte and uses OpenCV. As recommended on the opencv2 ROS Wiki page (http://www.ros.org/wiki/opencv2), I would like to change the way of including OpenCV from the old <depend package="opencv2" /> tag in the manifest.xml. Thus according to the wiki, I changed that entry to <rosdep name="opencv2"/> and edited my CMakeLists.txt to contain

find_package(OpenCV REQUIRED)
#define some target ...
target_link_libraries(my_target ${OpenCV_LIBRARIES})

If I try to build the package with rosmake I get errors during the linking process:

Linking CXX executable ../bin/mr
  ../lib/libmr_lib.so: undefined reference to `cv::waitKey(int)'
  ../lib/libmr_lib.so: undefined reference to `cv::imshow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&)'
  ../lib/libmr_lib.so: undefined reference to `cvMoveWindow'
  ../lib/libmr_lib.so: undefined reference to `cv::namedWindow(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
  collect2: ld returned 1 exit status
  make[3]: *** [../bin/mr] Error 1

libopencv2.4-dev is installed. Any help would be very appreciated! Thank you!


Originally posted by dinsn on ROS Answers with karma: 46 on 2013-02-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Thanks a lot for the answer! I've found out that I had an error in my CMakeLists. Not really used to the CMake building procedure... I'm building two libraries and one executable to which the libraries are linked. One of the libs uses OpenCV and I only used one target_link_libraries command to link everything instead of first linking OpenCV to the lib with one command and then linking the lib to the executable with another. So instead of

target_link_libraries(my_exec my_lib ${OpenCV_LIBS})

I'm now calling

target_link_libraries(my_lib ${OpenCV_LIBS})
target_link_libraries(my_exec my_lib)

and it works...


Originally posted by dinsn with karma: 46 on 2013-02-20

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.