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

ROS C++ Custom header not found

asked 2012-10-09 04:20:15 -0500

henge266 gravatar image

updated 2014-01-28 17:13:53 -0500

ngrennan gravatar image

Hi,

I created a ROS package with one main cpp file and another my_class.cpp file + my_class.h with some simple cpp code.

As long as I have all files in the src folder of the package, it works fine. As soon as I move the header file to another directory (for example my_package/include/my_package/my_class.h) and change the #include in main to the new path, the header file can't be found (error: include/sendPgmMarker/my_class.h: No such file or directory) when I try to compile.

I tried it like in this post: http://answers.ros.org/question/41873/ros-c-custom-class-compiler-and-linker/ but it doesn't work for me.

What changes do I have to make so the header can be found? Sure I could just let the header in the source folder, but I also want to add other external .h and .cpp files that are in other folders than my package.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2012-10-09 04:39:11 -0500

Lorenz gravatar image

updated 2012-10-09 04:39:38 -0500

Please make sure you have a look at the support wiki page and always tag your question to make sure the right people get notified.

How does your include line look like? I suspect something like:

#include <include/sendPgmMarker/my_class.h>

You must not specify the include subdirectory. It is added to the include path already. Try:

#include <senPgmMarker/my_class.h>
edit flag offensive delete link more
1

answered 2012-10-09 11:07:32 -0500

PerkinsJames gravatar image

@Lorenz sounds like he knows the answer. But also remember you may need to add a line in your CMakeLists.txt file like this:

include_directories(/your/path/here/)

edit flag offensive delete link more

Comments

Good hint. I just want to add that directory include at the root of a ros package is already added.

Lorenz gravatar image Lorenz  ( 2012-10-09 22:28:54 -0500 )edit
0

answered 2012-10-19 05:17:39 -0500

henge266 gravatar image

Thx for the answers. Problem solved with it.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-10-09 04:20:15 -0500

Seen: 4,489 times

Last updated: Oct 19 '12