ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Problem when compiling OpenCV with ROS

asked 2015-03-21 02:16:17 -0600

RuiH gravatar image

I am using rosbuild to build a project with OpenCV and ROS. The OpenCV version is 2.4.9, built and installed from source. The ROS version is indigo.

When I include the nonfree module of OpenCV (has SIFT and SURF) in my project files, I got a linking error something like"libopencv.so.2.4.9: undefined reference to ocl::integral()" after I build the ROS package using the CMakeList.txt.

I noticed that the compilation information in the terminal shows the compiler is also trying to link to some existing OpenCV 2.4.8 libs in the directory /lib/x86_64-linux-gnu/libgopencv*.so.2.4.8.

I realized that the OpenCV 2.4.8 might come with the CV_Bridge package when I install it. It seems the cmake is trying to link to some libs of 2.4.8 and also 2.4.9, which leads to some undefined reference. Another observation is that without ROS, I am able to compile a project with OpenCV (using pkg-config).

It seems the problem is the co-existence of two versions of OpenCV. How can I make it only link to the version I choose? I used find_package in the CMakeList file, but the compiler always tries to link to both version.

Thanks you very much. Rui

edit retag flag offensive close merge delete

Comments

Just to make sure: are you really using rosbuild or catkin?

gvdhoorn gravatar image gvdhoorn  ( 2015-03-21 04:12:37 -0600 )edit

I am using rosbuild.

RuiH gravatar image RuiH  ( 2015-03-21 16:30:36 -0600 )edit

Hi, I have the same problem when I use the nonfree module in ROS Indigo, have you found a solution for this error?

Dinl gravatar image Dinl  ( 2015-08-31 18:22:35 -0600 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2016-05-22 21:00:32 -0600

willSapgreen gravatar image

My system info:

  • Ubuntu 14.04.3 LTS
  • OpenCV 2.4.13
  • ROS Jade

I have the same link error but fix by switching the following content in CMakeLists.txt

  • ${OpenCV_LIBRARIES} ${catkin_LIBRARIES} in target_link_libraries
  • ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} in include_directories

OpenCV first, then catkin.

Hopefully this approach can resolve your problem.

edit flag offensive delete link more

Comments

I had the same problem, these procedure solve it! Thanks

michalszczepanski gravatar image michalszczepanski  ( 2017-04-14 04:32:20 -0600 )edit
0

answered 2015-08-31 19:59:23 -0600

Dinl gravatar image

updated 2015-09-01 02:09:05 -0600

gvdhoorn gravatar image

I had this error, this is the way that I found to solve it, apparently the problem is with OpenCL that is compiled by default with OpenCV, so you have to uninstall OpenCV and install again using the .sh file and modify the cmake line:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/ -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_OPENCL=OFF ..

Reference:

http://stackoverflow.com/questions/26... http://answers.ros.org/question/21069...

edit flag offensive delete link more
0

answered 2015-03-23 08:32:36 -0600

Wolf gravatar image

To make ROS surely building against your own version and not the version that comes with ROS you can use in your ROS-package's CMakeLists.txt

  find_package( OpenCV 2.4.9 EXACT REQUIRED )

2.4.9 is than your manually compiled version, which must then differ from the version that comes with ROS

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-03-21 02:16:17 -0600

Seen: 2,625 times

Last updated: May 22 '16