Working environment:
- Kubuntu 14.04 LTS 64bit
- ROS Indigo (up-to-date, full desktop install)
- OpenCV 2.4.8
For some unknown reason I decided to install the ros-indigo-opencv3 package which I regretted almost immediately due to the fact I also have the default version that comes with Ubuntu 14.04 - OpenCV 2.4.8.
At first I noticed that QtCreator was warning me of possible incompatibility between 2.4.8 and 3.0.0 when I was building my CMake project (you can see the CMakeLists.txt at the end of this post) using only
find_package(OpenCV REQUIRED)
Then the errors started flowing about some missing reference around the cv::stereoSGBM module. There seems to be some change in the namespaces or whatever and the library I am using uses the 2.x branch of OpenCV (found that the hard way obviously :D) hence I told myself - I guess I will remove the above mentioned ROS package for OpenCV 3.0.0 and stick with the 2.4.8.
After uninstalling that package it all went bananas. Even though in CMakeLists.txt of my project I explicitly pointed version 2.4.8. to be used
find_package(OpenCV 2.4.8 REQUIRED)
upon launching my node with roslaunch died immediately with the following error:
.../pmd_nano_node: error while loading shared libraries: libopencv_highgui.so.3.0: cannot open shared object file: No such file or directory
Huh...Okay...I checked if something has been left on my system (bad package maybe, which was unable to install and accordingly install properly?). For my surprise upon calling locate and piping the result with grep
user:~$ locate libopencv | grep 3.0
I got
/opt/ros/indigo/lib/libopencv_calib3d.so.3.0 /opt/ros/indigo/lib/libopencv_calib3d.so.3.0.0 /opt/ros/indigo/lib/libopencv_core.so.3.0 /opt/ros/indigo/lib/libopencv_core.so.3.0.0 ... (basically all opencv libs)
So something was left there after all (with something I mean everything :D). However imagine my surprise when I cd-ed to the /opt/ros/indigo/lib/ and found NOT A SINGLE file even remotely related to OpenCV let alone OpenCV 3.0.0.
Using pkg-config returns what I am expecting at least:
user:~$ pkg-config --cflags opencv -I/usr/include/opencv user:~$ pkg-config --libs opencv /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so ... -lopencv_calib3d ...
Note: I still don't know why --cflags never shows the opencv2 include folder (opencv2 as argument is not recognized by pkg-config)
Further investigation made me re-run my CMakeLists.txt for my project with the 3.0.0 version as requirement and indeed CMake now complains that only 2.4.8 is found. For what reason though the application tries to get the 3.0.0 version of OpenCV's shared libs remains to be seen.
Any advice or someone who has encountered such problem before?
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3) project(pmd_nano) SET(CMAKE_CXX_FLAGS "-std=c++0x -fpermissive -Wno-deprecated -Wno-sign-compare") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall") SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") SET(CMAKE_CXX_LINK_FLAGS_DEBUG "-pg") ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED COMPONENTS cv_bridge image_transport pcl_conversions pcl_msgs pcl_ros roscpp sensor_msgs std_msgs ) ## System dependencies are found with CMake's conventions find_package(Boost REQUIRED COMPONENTS system) find_package(PCL REQUIRED) find_package(OpenCV 2.4.8 REQUIRED COMPONENTS highgui imgproc) # Do NOT use OpenCV 3.0.0 or all hell will break loose. Package incompatilibity will be a fascinating thing to deal with... ################################### ## catkin specific configuration ## ################################### ## The catkin_package macro generates cmake config files for your package ## Declare things to be passed to dependent projects ## INCLUDE_DIRS: uncomment this if you package contains header files ## LIBRARIES: libraries you create in this project that dependent projects also need ## CATKIN_DEPENDS: catkin_packages dependent projects also need ## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( INCLUDE_DIRS include # LIBRARIES pmd_nano CATKIN_DEPENDS cv_bridge image_transport pcl_conversions pcl_msgs pcl_ros roscpp sensor_msgs std_msgs uvc_camera DEPENDS system_lib # Boost PCL OpenCV boost_system PCL opencv_highgui opencv_imgproc ) ########### ## Build ## ########### ## Specify additional locations of header files ## Your package locations should be listed before other locations # include_directories(include) include_directories( ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ) ## Declare a cpp library # add_library(pmd_nano # src/${PROJECT_NAME}/pmd_nano_node.cpp # ) ## Declare a cpp executable add_executable(pmd_nano_node src/pmd_nano_node.cpp src/ColorCamera.cpp src/DepthCamera.cpp src/PMDNano.cpp ) ## Add cmake target dependencies of the executable/library ## as an example, message headers may need to be generated before nodes # add_dependencies(pmd_nano_node pmd_nano_generate_messages_cpp) ## Specify libraries to link a library or executable target against target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES}) #link_directories(${PROJECT_NAME}_node ${Boost_LIBRARY_DIRS}) target_link_libraries(${PROJECT_NAME}_node boost_system) link_directories(${PROJECT_NAME}_node ${PCL_LIBRARY_DIRS}) target_link_libraries(${PROJECT_NAME}_node opencv_highgui opencv_imgproc) target_link_libraries(${PROJECT_NAME}_node pthread) target_link_libraries(pmd_nano_node ${PROJECT_SOURCE_DIR}/lib/libpmdaccess2.so) ############# ## Testing ## ############# ## Add gtest based cpp test target and link libraries # catkin_add_gtest(${PROJECT_NAME}-test test/test_pmd_nano.cpp) # if(TARGET ${PROJECT_NAME}-test) # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) # endif() ## Add folders to be run by python nosetests # catkin_add_nosetests(test)
EDIT:
Running sudo updatedb at least resolved the locate issue. The error during runtime is still present though.