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

Adding Header files to package

asked 2011-05-31 11:35:28 -0500

This may be so elementary, but by using functions from any header file in the "include/whatever_pkg_name" folder of the package, the compiler complains about "Undefined reference to...". What step am I missing? The include files are properly called from the source code.

edit retag flag offensive close merge delete


Looks like a linking problem. Are you calling functions from an outside package?
Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2011-05-31 11:45:30 -0500 )edit
No, it's nothing external. It's a very simple call to a function declared on a header file inside the "include" folder. I will send you the code for you to see what I'm talking about.
ubuntuslave gravatar image ubuntuslave  ( 2011-05-31 14:22:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-05-31 17:02:24 -0500

updated 2011-05-31 17:04:53 -0500

Actually, my problem was that I wasn't including the related .cpp files in the CMakeLists.txt, for example, I only had

rosbuild_add_executable(sphereo_node src/sphereo.cpp)

which was missing the remaining source files that implement the functions in the header file my_header.h, such as:

rosbuild_add_executable(sphereo_node src/sphereo.cpp src/my_header.cpp)

Thanks to Bill and Ivan!

edit flag offensive delete link more


Thanks! Searched for quite a while. Thanks for pointing out such a mistake for me. Now it seems so obvious... :)

niosus gravatar image niosus  ( 2012-12-11 01:50:50 -0500 )edit

Question Tools


Asked: 2011-05-31 11:35:28 -0500

Seen: 1,761 times

Last updated: May 31 '11