Ask Your Question
1

How to link a nodelet to external libraries?

asked 2011-09-23 14:57:13 -0500

updated 2011-09-26 15:33:19 -0500

I'm trying to use a nodelet with an external library. But when running the nodelet, it obviously complaints that it can't find some symbol which is in this external library.

I can link the regular node the library without problems. However, when I use the nodelet version, it complains. I'm certain that I'm not linking the nodelet to the library. I don't know how to.

If you know how to link a nodelet to an external library, please share your know-how-to.

The proposed SOLUTION in CMakeLists.txt relevant piece looks like the following:

set(MVIMPACT_LIBRARIES   mvDeviceManager)

# Nodelet:  
rosbuild_add_library(mv_bluefox_driver_nodelet src/nodelets.cpp src/camera.cpp) 
# Linking the nodelet to the mvDeviceManager library
target_link_libraries(mv_bluefox_driver_nodelet ${MVIMPACT_LIBRARIES})  

# Regular Node:
rosbuild_add_executable(camera_node src/camera_node.cpp src/camera.cpp)
target_link_libraries(camera_node ${MVIMPACT_LIBRARIES})
edit retag flag offensive close merge delete

Comments

Please show snippets of your CMakeLists.txt for both the node and the nodelet versions. That should help diagnose your problem.
joq gravatar image joq  ( 2011-09-24 03:12:36 -0500 )edit
Compile time problem or runtime problem?
Daniel Stonier gravatar image Daniel Stonier  ( 2011-09-24 03:28:51 -0500 )edit
Runtime problem with the error pointing at some function (DMR_Init) from the external library as: symbol lookup error: /DIR_TO_MY_PACKAGE/mv_bluefox_driver/lib/libmv_bluefox_driver_nodelet.so: undefined symbol: DMR_Init
ubuntuslave gravatar image ubuntuslave  ( 2011-09-25 07:58:23 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-09-26 00:49:49 -0500

target_link_libraries(mv_bluefox_driver_nodelet ${MVIMPACT_LIBRARIES})

The nodelet is basically a library with some programming voodoo that tells the nodelet manager which class to instantiate.

The target_link_libraries command links libraries against the binary that you name in its first argument. You already did it for the camera_node executable, and it works the same way for the mv_bluefox_driver_nodelet library.

edit flag offensive delete link more

Comments

Thanks, this was the solution.
ubuntuslave gravatar image ubuntuslave  ( 2011-09-26 15:27:41 -0500 )edit

Does this work with statically linked 3rd party libraries? Like, libs of which I only have a .a and a .hpp? If not, what else can I do to achieve that linkage?

Hendrik Wiese gravatar image Hendrik Wiese  ( 2018-01-15 07:28:02 -0500 )edit

It will probably work for x86_64, but not for i386, because static 32 bit libraries are usually not compiled with -fPIC for position independent code.

roehling gravatar image roehling  ( 2018-05-04 10:45:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-09-23 14:57:13 -0500

Seen: 782 times

Last updated: Sep 26 '11