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

Library includes are not copied properly at compile

asked 2015-12-20 13:31:24 -0600

Korken89 gravatar image

updated 2015-12-21 11:23:16 -0600

Hi all,

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.

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...

What am I missing to get the includes copied to have them included?

Full CMake files here: https://gitlab.com/korken89/cppViconS...

Thanks for all help!

EDIT:

To give a better background to my problem, what problem I am having (and am trying to fix) is that the headers for my library are not found at compile time for the packages dependent on my library. 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.

Am I looking to this problem in the wrong way for using custom libraries as packages?

EDIT2:

As requested, the build logg. Hope it helps!

/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.
CMakeFiles/ros_viconstream_node.dir/build.make:62: recipe for target 'CMakeFiles/ros_viconstream_node.dir/src/ros_viconstream_node.cpp.o' failed
make[2]: *** [CMakeFiles/ros_viconstream_node.dir/src/ros_viconstream_node.cpp.o] Error 1
CMakeFiles/Makefile2:539: recipe for target 'CMakeFiles/ros_viconstream_node.dir/all' failed
make[1]: *** [CMakeFiles/ros_viconstream_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
[ros_viconstream] <== '/home/emifre/Git/ros_ws/devel_ws/build/ros_viconstream/build_env.sh /usr/bin/make --jobserver-fds=3,6 -j' failed with return code '2'

Failed   <== ros_viconstream [ 2.1 seconds ]                                                                                                                                                  
[build] There were '1' errors:                                                                                                                                                                

Failed to build package 'ros_viconstream' because the following command:

# Command to reproduce:
cd /home/emifre/Git/ros_ws/devel_ws/build/ros_viconstream && /home/emifre/Git/ros_ws/devel_ws/build/ros_viconstream/build_env.sh /usr/bin/make --jobserver-fds=3,6 -j; cd -

# Path to log:
cat /home/emifre/Git/ros_ws/devel_ws/build/build_logs/ros_viconstream.log

Exited with return code: 2
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-12-21 05:23:33 -0600

gvdhoorn gravatar image

updated 2015-12-21 12:29:01 -0600

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.

edit flag offensive delete link more

Comments

I have this impression as I am not trying to install, just compiling the package for local use to my workspace. As I understood it, which might not be correct, is the install is only used when installing to the ROS libraries for permanent usage. Am I completely of here?

Korken89 gravatar image Korken89  ( 2015-12-21 05:31:52 -0600 )edit

I have updated the original question to describe the background problem. Thanks for the help!

Korken89 gravatar image Korken89  ( 2015-12-21 06:09:01 -0600 )edit

I have added the error log. Hope it helps!

Korken89 gravatar image Korken89  ( 2015-12-21 11:23:38 -0600 )edit

Thank you for explaining that! I am mostly only using CMake by itself and not with catkin as a build system, so the internal workings of the system is under learning. :) Thanks again for clearing this for me!

Korken89 gravatar image Korken89  ( 2015-12-22 07:21:16 -0600 )edit

Question Tools

Stats

Asked: 2015-12-20 13:31:24 -0600

Seen: 1,499 times

Last updated: Dec 21 '15