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

error: undefined reference to `SignbotController::establish_pub(ros::NodeHandle)'

asked 2017-09-07 05:49:14 -0500

FábioBarbosa gravatar image

Hi! I am having trouble finding the solution for this error. I known it is a linker error, but when i look at the /devel i found that the libsignbotcontroll.so exists. So i dont get why i'm getting this.

I am working on ubuntu 14.04 and ros indigo.

Heres my signbot_controll.h

#ifndef _SIGNBOT_CONTROLL_
#define _SIGNBOT_CONTROLL_

#include "ros/ros.h"
#include "std_msgs/String.h"

#include "trajectory_msgs/JointTrajectory.h"

 class SignbotController
 {
   private:
       ros::Publisher body_controll_pub;     //topic which will control the model in gazebo
       trajectory_msgs::JointTrajectory _message;

       void insert_jointnames();
   public:

        void establish_pub(ros::NodeHandle n);

        void publish();
  };
  #endif

Here's my signbot_control.cpp:

#include  <signbot_plugins/signbot_controll.h>

 void SignbotController::establish_pub(ros::NodeHandle n)
{
   //code ...
}

void SignbotController::insert_jointnames()
{
   //code ...
 }

 void SignbotController::publish()
 {
     ROS_INFO_STREAM("asd");
 }

Here's my main.cpp:

#include <signbot_plugins/signbot_controll.h>

 int main(int argc, char **argv)
 {
   ros::init(argc, argv, "signbot_core");
   ros::NodeHandle nh;

   SignbotController sigcon;

   sigcon.establish_pub(nh);

   if(ros::ok())
   {
     ros::spin();
   }

    ROS_INFO_STREAM("\n\t***** SHUTTING DOWN ********\n");
    return 0;
 }

Here's my cmakelist.txt:

cmake_minimum_required(VERSION 2.8.3)
project(signbot_plugins)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  message_generation
  roscpp
  trajectory_msgs)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
LIBRARIES signbot_plugins
CATKIN_DEPENDS
      message_runtime
      roscpp
      trajectory_msgs
#  DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
 include
 ${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
 add_library(classtranslator src/classtranslator.cpp)
 add_library(signbotcontroll src/signbot_controll.cpp)

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
  add_dependencies(classtranslator ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
  add_dependencies(signbotcontroll ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

  target_link_libraries(classtranslator ${catkin_LIBRARIES})
  target_link_libraries(signbotcontroll ${catkin_LIBRARIES})

  add_executable(signbot_core_node src/signbot_core.cpp)
  add_dependencies(signbot_core_node signbot_core_cpp)
  target_link_libraries(signbot_core_node ${catkin_LIBRARIES})

Can anyone help me? Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-09-07 05:55:10 -0500

FábioBarbosa gravatar image

Found out my error. It was in the CMakeList.txt file.

I have this:

  target_link_libraries(signbot_core_node ${catkin_LIBRARIES})

and it should be like this:

  target_link_libraries(signbot_core_node signbotcontroll ${catkin_LIBRARIES})
edit flag offensive delete link more

Comments

1

Suggestion: if there is no need to make classtranslator and signbotcontroll libraries, then just add all of them as source entries to your signbot_core_node binary:

add_executable(signbot_core_node
  src/signbot_core.cpp
  src/classtranslator.cpp
  src/signbot_controll.cpp)
gvdhoorn gravatar image gvdhoorn  ( 2017-09-07 06:43:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-07 05:49:14 -0500

Seen: 135 times

Last updated: Sep 07 '17