'ROS catkin_make error undefinend reference for a simple C program lib
I'm trying to create a simple node which uses a simple C library (libarithmetic.a) which had been built outside the ROS framework.
trying to use the library add(...) function in my package node results in undefined reference error .I assume i have missed something in the CMakeLists.txt which cannot figure out what exactly it is.
below are screenshots of my CMakeLists.txt and the catkin_make log messages
Thanks
cmake_minimum_required(VERSION 3.0.2)
project(example_01)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
)
catkin_package(
#INCLUDE_DIRS include
#LIBRARIES example_01
#CATKIN_DEPENDS roscpp rospy std_msgs
#DEPENDS system_lib
)
include_directories(
include
${catkin_INCLUDE_DIRS}
/home/hanoch/my_playfield/inc
)
add_executable(${PROJECT_NAME}_node
src/example_01.cpp
)
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
# ${EXT_LIBRARY}
/home/hanoch/my_playfield/lib/libarithmetic.a
)
the catkin_make result is
[ 50%] Linking CXX executable /home/hanoch/ros_workspaces/hanoch_ws/devel/lib/example_01/example_01_node
/usr/bin/ld: CMakeFiles/example_01_node.dir/src/example_01.cpp.o: in function `main':
example_01.cpp:(.text+0x4fe): undefined reference to `add(float, float)'
collect2: error: ld returned 1 exit status
make[2]: *** [example_01/CMakeFiles/example_01_node.dir/build.make:102: /home/hanoch/ros_workspaces/hanoch_ws/devel/lib/example_01/example_01_node] Error 1
make[1]: *** [CMakeFiles/Makefile2:418: example_01/CMakeFiles/example_01_node.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Invoking "make -j4 -l4" failed
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
