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

Revision history [back]

click to hide/show revision 1
initial version

I have added: include_directories(${catkin_INCLUDE_DIRS} include) and catkin_package( DEPENDS pthread INCLUDE_DIRS ${catkin_INCLUDE_DIRS} include LIBRARIES ${PROJECT_NAME} ... )

Which according to here should be enough: http://docs.ros.org/api/catkin/html/h...

The page you refer to also mentions all the CMake install rules you have to add for files to be installed to the correct locations. Only auto-generated headers (like those from the various msg code generators) get their install targets automatically added.

See the Installing section of the Building and installing C++ libraries and headers page you linked.

I have added: include_directories(${catkin_INCLUDE_DIRS} include) and catkin_package( DEPENDS pthread INCLUDE_DIRS ${catkin_INCLUDE_DIRS} include LIBRARIES ${PROJECT_NAME} ... )

Which according to here should be enough: http://docs.ros.org/api/catkin/html/h...

The page you refer to also mentions all the CMake install rules you have to add for files to be installed to the correct locations. Only auto-generated headers (like those from the various msg code generators) get their install targets automatically added.

See the Installing section of the Building and installing C++ libraries and headers page you linked.

Could you indicate which text on that page gave the impression that no install rules were necessary for the headers to be installed?

I have added: include_directories(${catkin_INCLUDE_DIRS} include) and catkin_package( DEPENDS pthread INCLUDE_DIRS ${catkin_INCLUDE_DIRS} include LIBRARIES ${PROJECT_NAME} ... )

Which according to here should be enough: http://docs.ros.org/api/catkin/html/h...

The page you refer to also mentions all the CMake install rules you have to add for files to be installed to the correct locations. Only auto-generated headers (like those from the various msg code generators) get their install targets automatically added.

See the Installing section of the Building and installing C++ libraries and headers page you linked.

Could you indicate which text on that page gave the impression that no install rules were necessary for the headers to be installed?


Edit: I misunderstood your question.

I have been compiling a library and made it ROS compatible - and everything works except that the includes are not copied to the devel/lib/PACKAGE folder.

Headers are never copied to devel/lib/PKG. Afaik the only headers to be present in the devel space are the ones auto-generated by gencpp and friends, and those would go into devel/include/PKG. If you're not installing, catkin will set up the include paths such that they point to the src/PKG/include/.. directories, which avoids the need to copy files around. Only an install space will have pkg headers in install/include/PKG, but then only if the necessary install statements have been added to the CMakeLists.txt.

As to your actual issue: please describe it more clearly. Are you getting errors telling you that headers cannot be found at compile time?

I have added: include_directories(${catkin_INCLUDE_DIRS} include) and catkin_package( DEPENDS pthread INCLUDE_DIRS ${catkin_INCLUDE_DIRS} include LIBRARIES ${PROJECT_NAME} ... )

Which according to here should be enough: http://docs.ros.org/api/catkin/html/h...

The page you refer to also mentions all the CMake install rules you have to add for files to be installed to the correct locations. Only auto-generated headers (like those from the various msg code generators) get their install targets automatically added.

See the Installing section of the Building and installing C++ libraries and headers page you linked.

Could you indicate which text on that page gave the impression that no install rules were necessary for the headers to be installed?


Edit: I misunderstood your question.

I have been compiling a library and made it ROS compatible - and everything works except that the includes are not copied to the devel/lib/PACKAGE folder.

Headers are never copied to devel/lib/PKG. Afaik the only headers to be present in the devel space are the ones auto-generated by gencpp and friends, and those would go into devel/include/PKG. If you're not installing, catkin will set up the include paths such that they point to the src/PKG/include/.. directories, which avoids the need to copy files around. Only an install space will have pkg headers in install/include/PKG, but then only if the necessary install statements have been added to the CMakeLists.txt.

As to your actual issue: please describe it more clearly. Are you getting errors telling you that headers cannot be found at compile time?


Edit2: first:

And the catkin looks in the devel/lib/PKG folder for the .so file and the headers, but the headers are not there, hence the previous question.

catkin doesn't look for headers in devel/lib/PKG, in fact, it doesn't look for anything, it is a build tool. The compiler may look in devel/lib/PKG, but only if you made CMake (underlying catkin) add that path to the include_directories(..).

/home/emifre/Git/ros_ws/devel_ws/src/ros_viconstream/src/ros_viconstream_node.cpp:2:37: fatal error: viconstream/viconstream.h: No such file or directory
compilation terminated.

From this error message, it seems the compiler is looking for the viconstream.h file in a directory named viconstream, which should be on the include path. Your CMakeLists.txt adds only the include directory, but there is no include/viconstream sub dir, so the compiler will never be able to find that file, no matter how you configure the include path.

Possible solutions:

  1. change #include <viconstream/viconstream.h> to #include <viconstream.h>
  2. create a sub directory viconstream in your pkg's include directory and place viconstream.h in it

I recommend option 2.

I have added: include_directories(${catkin_INCLUDE_DIRS} include) and catkin_package( DEPENDS pthread INCLUDE_DIRS ${catkin_INCLUDE_DIRS} include LIBRARIES ${PROJECT_NAME} ... )

Which according to here should be enough: http://docs.ros.org/api/catkin/html/h...

The page you refer to also mentions all the CMake install rules you have to add for files to be installed to the correct locations. Only auto-generated headers (like those from the various msg code generators) get their install targets automatically added.

See the Installing section of the Building and installing C++ libraries and headers page you linked.

Could you indicate which text on that page gave the impression that no install rules were necessary for the headers to be installed?


Edit: I misunderstood your question.

I have been compiling a library and made it ROS compatible - and everything works except that the includes are not copied to the devel/lib/PACKAGE folder.

Headers are never copied to devel/lib/PKG. Afaik the only headers to be present in the devel space are the ones auto-generated by gencpp and friends, and those would go into devel/include/PKG. If you're not installing, catkin will set up the include paths such that they point to the src/PKG/include/.. directories, which avoids the need to copy files around. Only an install space will have pkg headers in install/include/PKG, but then only if the necessary install statements have been added to the CMakeLists.txt.

As to your actual issue: please describe it more clearly. Are you getting errors telling you that headers cannot be found at compile time?


Edit2: first:

And the catkin looks in the devel/lib/PKG folder for the .so file and the headers, but the headers are not there, hence the previous question.

catkin doesn't look for headers in devel/lib/PKG, in fact, it doesn't look for anything, it is a build tool. The compiler may look in devel/lib/PKG, but only if you made CMake (underlying catkin) add that path to the include_directories(..).

/home/emifre/Git/ros_ws/devel_ws/src/ros_viconstream/src/ros_viconstream_node.cpp:2:37: fatal error: viconstream/viconstream.h: No such file or directory
compilation terminated.

From this error message, it seems the compiler is looking for the viconstream.h file in a directory named viconstream, which should be on the include path. Your CMakeLists.txt adds only the include directory, but there is no include/viconstream sub dir, so the compiler will never be able to find that file, no matter how you configure the include path.

Possible solutions:

  1. change #include <viconstream/viconstream.h> to #include <viconstream.h>
  2. create a sub directory viconstream in your pkg's include directory and place viconstream.h in it

I recommend option 2.

PS: this has actually nothing to do with catkin, nor CMake. Using any other build tool (or even writing Makefiles by hand) would have resulted in exactly the same error.