0
$\begingroup$

Rosanswers logo

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.


Originally posted by henge266 on ROS Answers with karma: 1 on 2012-10-09

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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>

Originally posted by Lorenz with karma: 22731 on 2012-10-09

This answer was ACCEPTED on the original site

Post score: 4

$\endgroup$
0
$\begingroup$

Rosanswers logo

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


Originally posted by PerkinsJames with karma: 506 on 2012-10-09

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by Lorenz on 2012-10-09:
Good hint. I just want to add that directory include at the root of a ros package is already added.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.