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

Undefined Reference using Cereal_Port, -l doesn't fix

asked 2013-11-15 07:43:02 -0600

Andrew Capodieci gravatar image

updated 2013-11-15 08:53:01 -0600

Hello, I'm currently writing two ros_nodes. One is finished, and captures data from a gyro. It uses the ros cereal_port library found in the following stack: /opt/ros/fuerte/stacks/serial_communication/cereal_port/lib

I have no issues with this node compiling, and it runs perfectly in Fuerte on Ubuntu 12.04 precise.

I'm now trying to use the cereal_port library in another package, but I keep getting undefined references in libcereal_port.so to various boost functions. I've been at this for 2 days now, and I don't understand why adding -lboost_thread-mt is not enough for the undefined reference to be resolved. I've validated that the path/file for libboost_thread-mt.so exist, but I cannot eliminate the problem.

Here are the manifest.xml and CMakeLists.txt for the gyro rosnode that is currently compiling and executing properly:

manifest.xml:

<package>
<description brief="kvh_dsp_1750_ros_interface">

 kvh_dsp_1750_ros_interface

</description>
<author>am3p-pc2</author>
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http:// ros.org/wiki/kvh_dsp_1750_ros_interface</url>

<depend package="roscpp"/>
<depend package="cereal_port"/>

<export>
<cpp cflags="-I${prefix}/include" lflags="-Wl,-rpath,$prefix}/lib -L${prefix}/lib -lKVH_DSP1750"/>
</export>
</package>

CMakeLists.txt:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_genmsg()

rosbuild_add_library(KVH_DSP1750 include/KVHDSP1750.h src/KVHDSP1750.cpp)

rosbuild_add_executable(dsp1750_node src/kvh_dsp_1750_ros_interface.cpp)
target_link_libraries(dsp1750_node KVH_DSP1750)

Here are the manifest.xml and CMakeLists.txt for the GPS rosnode that is NOT currently building:

manifest.xml:

<package>
<description brief="novatel_oem628_driver">

   novatel_oem628_driver

</description>
<author>am3p-pc2</author>
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http:// ros.org/wiki/novatel_oem628_driver</url>

<depend package="roscpp"/>
<depend package="cereal_port"/>

<export>
<cpp cflags="-I${prefix}/include" lflags="-Wl,-rpath,$prefix}/lib -L${prefix}/lib -lNOVATEL_LIB"/>
</export>
</package>

CMakeLists.txt:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

# Set the build type.  Options are:
#  Coverage       : w/ debug symbols, w/o optimization, w/ code-coverage
#  Debug          : w/ debug symbols, w/o optimization
#  Release        : w/o debug symbols, w/ optimization
#  RelWithDebInfo : w/ debug symbols, w/ optimization
#  MinSizeRel     : w/o debug symbols, w/ optimization, stripped binaries
#set(ROS_BUILD_TYPE RelWithDebInfo)

rosbuild_init()

#set the default path for built executables to the "bin" directory
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
#set the default path for built libraries to the "lib" directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

#uncomment if you have defined messages
#rosbuild_genmsg()
#uncomment if you have defined services
#rosbuild_gensrv()
FIND_PACKAGE(Boost COMPONENTS thread)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})

message("\${Boost_INCLUDE_DIR} = ${Boost_INCLUDE_DIR}")
message("\${Boost_LIBRARIES} = ${Boost_LIBRARIES}")

rosbuild_add_library(NOVATEL_LIB include/novatel.h src/lib/novatel.cpp)
#rosbuild_add_library(cereal_port /opt/ros/fuerte/stacks/serial_communication/cereal_port/include/cereal_port ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-15 09:47:15 -0600

Andrew Capodieci gravatar image

To answer my own question, I had to edit the CMakeLists.txt file for the cereal_port library itself, and rebuild it. I added the following lines to the cereal_port CMakeLists.txt:

rosbuild_add_boost_directories()
rosbuild_add_library(cereal_port src/CerealPort.cpp)
rosbuild_link_boost(cereal_port thread)

I must not have been using any of the functions in the cereal_port library that depended on boost in the first rosnode I wrote that used cereal_port. I'm not sure why a ROS package I installed using rosdep install wouldn't have the proper dependencies linked correctly.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-11-15 07:43:02 -0600

Seen: 355 times

Last updated: Nov 15 '13