How to import external Static libraries(.a) and header files(.h)
I am trying to create a ros node on raspberry pi for a sensor which requires an external library (and header files) to be used. I am having trouble finding enough documentation on how to change the cmakelists.txt file to include them. Adding the targetlinklibraries did not resolve the issue.
all external libraries are in a folder called lib and all header files are in a folder called include
This is the file for reference:
cmake_minimum_required(VERSION 2.8.3)
project(ros_tutorials_topic)
find_package(catkin REQUIRED COMPONENTS
message_generation
roscpp
rospy
std_msgs
genmsg
geometry_msgs
)
add_message_files(
FILES
my_msg.msg
sensData.msg
)
generate_messages(
DEPENDENCIES
std_msgs
geometry_msgs
)
catkin_package(
# INCLUDE_DIRS include
LIBRARIES ros_tutorials_topic message_runtime
CATKIN_DEPENDS roscpp std_msgs geometry_msgs
# DEPENDS system_lib
)
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(topic_publisher src/topic_publisher.cpp)
add_dependencies(topic_publisher ros_tutorials_topic_generate_messages_cpp)
target_link_libraries(topic_publisher ${catkin_LIBRARIES}
/home/pi/catkin_ws/src/acconeer_sensor/lib/libacconeer.a
/home/pi/catkin_ws/src/acconeer_sensor/lib/libacconeer_a111_r2c.a
/home/pi/catkin_ws/src/acconeer_sensor/lib/libacc_service.a
)
Asked by acorn2t1 on 2019-06-20 10:27:55 UTC
Comments
Can you include exact copies of the error messages your getting as well. We need to know more than just 'it doesn't work'
One thing I can spot though is that
# INCLUDE_DIRS include
is still commented out so your build will not be looking in the include directory you've created.Asked by PeteBlackerThe3rd on 2019-06-20 10:41:19 UTC
The error we are getting is undefined reference to "acc_service()". (acc_service() is a function defined inside the library)
Asked by acorn2t1 on 2019-06-24 02:40:38 UTC