How to use external c++ function in node main function
i have a package called "my_serial_example" in the source directory of this package i have a "receiveSerialData.cpp" which include the executable node and "TerminalCommand.h" and "TerminalCommand.cpp", like this:
TerminalCommand.h
class Command
{
//Some #define
private:
public:
//Some variable
bool parseCommand(uint8_t _command);
void initCommand();
};
TerminalCommand.ccp
#include "TerminalCommand.h"
bool Command::parseCommand(uint8_t _receivedByte)
{
//Some Operation
}
and in the "receiveSerialData.cpp"
#include"TerminalCommand.h"
Command myRecivedCommand;
int main (int argc, char** argv)
{
ros::init(argc, argv, "receiveSerialData");
ros::NodeHandle nh;
bool x = myRecivedCommand.parseCommand;
}
when i am build the package "my_serial_example", i got this error
undefined reference to `Command::parseCommand(unsigned char)'
i think the problem in "CMakeLists.txt" file which look like:
cmake_minimum_required(VERSION 2.8.3)
project(my_serial_example)
find_package(catkin REQUIRED COMPONENTS
roscpp
serial
std_msgs
tf
roslib
)
catkin_package(
CATKIN_DEPENDS
serial
std_msgs
roscpp
)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(receiveSerialData src/receiveSerialData.cpp)
target_link_libraries(receiveSerialData ${catkin_LIBRARIES})
have any solve please, how to link my function to my executable node thank