Catkin/Cmake includes directories as -isystem (Custom OpenCV)

asked 2017-09-29 04:06:22 -0500

CJuette gravatar image


I am trying to get a custom-built version of OpenCV 3.3.0 (with CUDA-support) to work with ROS Kinetic on a NVIDIA Jetson TX1. OpenCV is installed to /usr/local.

I have tried following this and this answer, but they didn't work for me.

My CMakeLists.txt-file (currently) looks like this:

cmake_minimum_required(VERSION 2.8.3)

    PATHS /usr/local

find_package(catkin REQUIRED COMPONENTS
    # ... others ...


# add_executable, add_dependencies... 


I also downloaded and built the vision_opencv-package in my workspace. When building a node, Cmake finds the correct version of OpenCV.

-- Found OpenCV: /usr/local (found suitable version "3.3.0", minimum required is "3")

However the node still includes the wrong header-files and is linked against the ROS-OpenCV-Version, as I can find out at Run-Time in my code. Looking at the build-commands with VERBOSE=1 I can see that the include-directories are part of the command, but are included with the -isystem-Flag, meaning the ROS-Includes (included with -I) will be preferred.

/usr/bin/c++ -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"<package_name>\" -isystem /usr/local/include -isystem /usr/local/include/opencv -I<workspace>/src/vision_opencv-kinetic/cv_bridge/include -I/opt/ros/kinetic/include -I/opt/ros/kinetic/include/opencv-3.2.0-dev -I/opt/ros/kinetic/include/opencv-3.2.0-dev/opencv -I/opt/ros/kinetic/share/xmlrpcpp/cmake/../../../include/xmlrpcpp  -std=c++11 -o CMakeFiles/<node_name>.dir/src/<node_name>.cpp.o -c <workspace>/src/<package_name>/src/<node_name>.cpp

This is the linker command. I tried to shorten it a bit by using <ros_libs>=/opt/ros/kinetic/lib and <local_libs>=/usr/local/lib.

/usr/bin/c++ CMakeFiles/<node_name>.dir/src/<node_name>.cpp.o  -o <workspace>/devel/lib/<package_name>/<node_name>  -L/usr/local/cuda-8.0/lib64 -rdynamic <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <local_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ <ros_libs>/ ...
edit retag flag offensive close merge delete


Are we sure it's not the ROS OpenCV package setting the isystem flag? Related issue: ros/catkin#428 (but it's old, so just for reference).

gvdhoorn gravatar image gvdhoorn  ( 2017-09-29 05:14:00 -0500 )edit

I'm not sure, but I don't think so. I've tried adding Paths manually in include_directories, and I discovered something weird: When I add /usr/local it gets added to the command with the -I-flag like it should. However when I manually add /usr/local/include it gets added with -isystem.

CJuette gravatar image CJuette  ( 2017-10-04 02:33:03 -0500 )edit