0
$\begingroup$

Rosanswers logo

Hi,

I have the similiar situation as http://answers.ros.org/question/264934/load-plugin-where-base-class-exists-in-another-project/ where I build a plugin where the base class is in another package. I noticed the upon loading the plugin I will get "undefined reference" errors if miss the line:

target_link_libraries(test_plugins ${catkin_LIBRARIES} ${PROJECT_NAME})

However I am still wondering if plugins have to be linked to all the ${catkin_LIBRARIES} of the project.

Does someone know if this is best practice? I noticed that it increases the shared object by factors.


Originally posted by agutenkunst on ROS Answers with karma: 90 on 2017-07-06

Post score: 0


Original comments

Comment by gvdhoorn on 2017-07-06:
May I suggest a title change? You're question is really more about linking when creating plugins, but your title does not reflect that at all.

Comment by agutenkunst on 2017-07-06:
You are right. Changed it.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, you'll need to link against whatever your plugin needs, as the future host of your plugin (which could be anything) does not (and cannot) 'know' what dependencies a plugin might have.

Symbols needed by dynamic libraries are resolved at run-/load time by the loader, and if something can't be found, you'll run into the undefined reference errors you mention.

You could potentially save some bytes by verifying which symbols your potential host(s) already have access to, but that will probably be quite involved, and in the end will make your plugin rather brittle: if the host(s) ever change their dependencies (ie: the libraries they load), your plugin will have a problem.


Originally posted by gvdhoorn with karma: 86574 on 2017-07-06

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.