How to use newer versions of opencv in Fuerte
Recently I had an issue building my own package depending on cv_bridge package and a custom-built opencv library. I was able to solve the linking problem in previous ROS versions here, but later I found out that the package was in fact using the fuerte/include/opencv header, but linking with the right /usr/local/lib libs. Everything should be OK if the headers were not changed, but if they do, it will fail.
To find out why I listed all the include dirs in cmake, and I got the following result(only the first 5 items)
-- --> include dir='/home/kai/Projects/my_pkg/include' -- --> include dir='/opt/ros/fuerte/include' -- --> include dir='/usr/local/include/opencv' -- --> include dir='/usr/local/include' -- --> include dir='/opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include'
As can be seen, the ros/fuerte/include dir precedes the /usr/local/include; as a result, even if I can find my custom-built opencv headers and libraries through FindPackage()
in CMakeLists.txt from setting the right $CMAKE_PREFIX_PATH env var, the #include <opencv.h>
will still find the ros/fuerte/include/opencv
first.
To reproduce this problem, try the following:
- Install ros fuerte opencv package
- Download opencv from opencv.org and make&make install it with your own build options(namely, with CUDA)
- Create a package depending on cv_bridge package
- Follow the link provided above to make sure your CMakeLists.txt can use
FindPackage()
to find your custom built opencv package(default in /usr/local) - Write some pieces of code using opencv's specific features(CUDA, if you built with it)
rosmake
orcmake ..& make
it.- Check the depend.make file under your_pkg/build/CMakeFiles/your_pkg.dir, find opencv occurrences, it will be
/opt/ros/fuerte/include/opencv
, not/usr/local/include/opencv
So what I am writing to ask is, is there any way to make my own opencv include path precedes the ros include path? Or it won't be found because there is a opencv/opencv2 dir in the fuerte/include
dir and they will be found first. Currently I renamed ROS's provided opencv&opencv2 dirs names to hide them from being found, but I think there should be some better way.
Thanks in advance.
And, I am under ubuntu 12.04 32-bit. No catkin build or ros_ws(still uses the old fashioned $ROS_PACKAGE_PATH way).