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 close merge delete

Sort by » oldest newest most voted

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>

more

@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/)

more

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

( 2012-10-09 22:28:54 -0500 )edit

Thx for the answers. Problem solved with it.

more