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

Revision history [back]

click to hide/show revision 1
initial version

You have a function my_test_func() declared in node_1.h and implemented in node_1.cpp. When you try to use it in node_2.cpp, the linker is missing it's implementation, as only declaration in node_1.h is known, but implementation of that function is missing.

To solve this you have 2 options: - remove implementation of my_test_func() from node_1.cpp and add it to node_1.h file (so that function is declared and implemented in header file) - Create a class Node1 (in node_1.h/cpp) with my_test_func() public member function of that class. Then create an instance of this class in node_2.cpp and call my_test_func() as member of this class, i.e.

#include "package/node_1.h"

int main()
{
    // ...
    Node1 n1;
    n1.my_test_func();
}