Ask Your Question

opencv pkg-config configuration problem in ubuntu with fuerte

asked 2012-07-17 03:26:53 -0500

updated 2012-07-17 22:40:17 -0500

After ros-fuerte installation in ubuntu 12.04, I am having problems to compile my opencv programs.
I am getting the following results:

/usr/bin/ld: cannot find -lopencv_nonfree
/usr/bin/ld: cannot find -lopencv_photo
/usr/bin/ld: cannot find -lopencv_stitching
/usr/bin/ld: cannot find -lopencv_ts
/usr/bin/ld: cannot find -lopencv_videostab

I realised that ros-fuerte packages for ubuntu changes default pkg-config configuration file for opencv library, pointing to the files in the ros installation.

# pkg-config --cflags opencv
-I/opt/ros/fuerte/include/opencv -I/opt/ros/fuerte/include 

# pkg-config --libs opencv 
-L/opt/ros/fuerte/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab
  • Why is ros changing the default opencv configuration for compilation?
  • Can't just use a different pkg-config configuration file such as ros-opencv.pc?
  • And, in case the default configuration must be changed, why it is not compatible with previous opencv configurations?


I have found the problem. The script of ros-fuerte updates the variable that uses pkg-config to find the configuration files


Now pkg-config gives preference to ROS configuration.

So the answer now is: Is this really needed to be in the script?

Maybe rosmake can set this variable when using pkg-config to configure the compilation.

edit retag flag offensive close merge delete


Have you installed ros-feurte-vision-opencv using apt-get?

Mani gravatar image Mani  ( 2012-07-17 07:09:18 -0500 )edit

Yes. I installed all ros fuerte using apt-get system.

Pablo Urcola gravatar image Pablo Urcola  ( 2012-07-17 22:34:01 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-12-13 09:31:28 -0500

BeLioN gravatar image

When pkg-config has to find your package, it looks for the right paths in the PKG_CONFIG_PATH variable. And the order of the paths in this variable actually matters. If you do:

export PKG_CONFIG_PATH=/opt/ros/fuerte/lib/pkgconfig:$PKG_CONFIG_PATH

You are giving priority to the packages of ROS, because it is found first in the list of paths.

You can use the same to override the ROS package and use the standalone OpenCV. After sourcing the file /opt/ros/fuerte/ you can add the path to the standalone OpenCV installation (note that I add the path in the left side of the variable):

export PKG_CONFIG_PATH=$HOME/bin/opencv/lib/pkgconfig/:${PKG_CONFIG_PATH}

If you want to change to ROS packages, just source /opt/ros/fuerte/ again.

edit flag offensive delete link more

answered 2014-03-14 04:51:34 -0500

Latif Anjum gravatar image

so what is the solution?

I have these lines


already in my fuerte file but it still cannot find opencv packages. Should I delete them?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-07-17 03:26:53 -0500

Seen: 4,150 times

Last updated: Mar 14 '14