Skip to content

undefined reference to `ExampleRosClass::ExampleRosClass(ros::NodeHandle*)' #11

Description

@ibrahimqazi

Hello sir,
I am studying the section "using_a_ros_library", when I compile my package it gives me this error:

CMakeFiles/ros_class_test_node.dir/src/example_ros_class_test_main.cpp.o: In function `main':
example_ros_class_test_main.cpp:(.text+0x256): undefined reference to `ExampleRosClass::ExampleRosClass(ros::NodeHandle*)'
collect2: error: ld returned 1 exit status
using_a_ros_library/CMakeFiles/ros_class_test_node.dir/build.make:112: recipe for target '/home/ibrrahim/catkin_workspaces/learning_ros_ws/devel/lib/using_a_ros_library/ros_class_test_node' failed
make[2]: *** [/home/ibrrahim/catkin_workspaces/learning_ros_ws/devel/lib/using_a_ros_library/ros_class_test_node] Error 1
CMakeFiles/Makefile2:3035: recipe for target 'using_a_ros_library/CMakeFiles/ros_class_test_node.dir/all' failed
make[1]: *** [using_a_ros_library/CMakeFiles/ros_class_test_node.dir/all] Error 2
Makefile:140: recipe for target 'all' failed

My CMakeLists.txt file contents are:

cmake_minimum_required(VERSION 3.0.2)
project(using_a_ros_library)

find_package(catkin REQUIRED COMPONENTS
  creating_a_ros_library
  roscpp
  std_msgs
  std_srvs
)



catkin_package(
  # INCLUDE_DIRS include
  LIBRARIES example_ros_library
  CATKIN_DEPENDS creating_a_ros_library roscpp std_msgs std_srvs
  #DEPENDS system_lib
)

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


include_directories(
  #include
  ${catkin_INCLUDE_DIRS}
  ${creating_a_ros_library}
)


add_executable(ros_class_test_node src/example_ros_class_test_main.cpp)


target_link_libraries(ros_class_test_node ${catkin_LIBRARIES})

Please note that I am not using catkin simple package. Any advice will be highly appreciated.
Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions