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

RQT Custom Plugin: undefined symbol

asked 2017-11-24 10:03:42 -0500

Femer gravatar image

updated 2017-11-27 01:57:50 -0500

Hi everyone,

I am trying to have a simple RQT template to use in the future whenever I need to create a new GUI. The main idea of my minimal (not) working example (MNWE) is to have:

  • TemplatePlugin class that is exported as plugin for RQT;
  • TemplateWidget class that implements an RQT widget that is then included in TemplatePlugin.

This is a similar approach employed in rqt_multiplot where there's one main MultiplotPlugin that includes different widgets.

I'm able to compile my (MNWE) , but when I launch the gui I get the following error:

[ERROR] [1511538332.555287110]: Failed to load nodelet [rqt_template_plugin::TemplatePlugin_0] of type [rqt_template_plugin::TemplatePlugin]: Failed to load library /home/marco/catkin_ws/devel/lib//librqt_template_plugin.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library (Poco exception = /home/marco/catkin_ws/devel/lib//librqt_template_plugin.so: undefined symbol: _ZN19rqt_template_plugin14TemplatePluginD1Ev)

RosPluginlibPluginProvider::load_explicit_type(rqt_template_plugin::TemplatePlugin) failed creating instance PluginManager._load_plugin() could not load plugin "rqt_template_plugin::TemplatePlugin": RosPluginlibPluginProvider.load() could not load plugin "rqt_template_plugin::TemplatePlugin"

Even though the error suggests that I don't have the macro "PLUGINLIB_EXPORT_CLASS", it is actually present in my cpp file: PLUGINLIB_EXPORT_CLASS. So I guess I am not linking the plugin at compile time correctly and then having issue at run time. I tried the solution proposed in this other thread question/215487, but adding "set(CMAKE_AUTOMOC ON)" to make CMakeLists.txt file prevents me compiling the whole package.

Update of 27/11/2017

Running the command

for f in $(find ~/catkin_ws -name "*.so"); do echo $f; objdump -TC $f | grep _ZN19rqt_template_plugin14TemplatePluginD1Ev; done

the symbol "_ZN19rqt_template_plugin14TemplatePluginD1Ev" is not found at all. Whereas if I run the command

for f in $(find ~/catkin_ws -name "*.so"); do echo $f; objdump -TC $f | grep rqt_template_plugin; done

Then I obtain:

/home/marco/catkin_ws/devel/lib/librqt_template_plugin.so
/home/marco/catkin_ws/devel/lib/librqt_template_plugin.so:     file format elf64-x86-64
0000000000000000      D  *UND*  0000000000000000              
rqt_template_plugin::TemplatePlugin::~TemplatePlugin()
0000000000000000      D  *UND*  0000000000000000              
rqt_template_plugin::TemplatePlugin::~TemplatePlugin()
0000000000000000      D  *UND*  0000000000000000              non-virtual thunk to 
rqt_template_plugin::TemplatePlugin::~TemplatePlugin()
0000000000000000      D  *UND*  0000000000000000              non-virtual thunk to 
rqt_template_plugin::TemplatePlugin::~TemplatePlugin()

* End Update *

I was wondering if anyone could give me a hint about what I should try next.

Thanks a lot,

Marco.

edit retag flag offensive close merge delete

Comments

Not an answer but maybe helps. You can see if the symbol exists in any library on your catkin_ws with:

for f in $(find ~/catkin_ws -name "*.so"); do echo $f; objdump -TC $f | grep _ZN19rqt_template_plugin14TemplatePluginD1Ev; done

If is defined, it will be printed after the name of the .so

Ruben Alves gravatar image Ruben Alves  ( 2017-11-24 13:46:55 -0500 )edit

If you see that the symbol is defined, then is just because it's not being loaded at runtime.

See if the path to the library is on your LD_LIBRARY_PATH with: env | grep LD_LIBRARY_PATH

Ruben Alves gravatar image Ruben Alves  ( 2017-11-24 13:48:20 -0500 )edit

Hi Ruben, thanks for your comment! With your first command the symbol was not found at all. Instead if I grep rqt_template then I get the result I just pasted in the updated question ... any idea?

Femer gravatar image Femer  ( 2017-11-27 01:52:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2017-11-28 07:37:58 -0500

Hi @Femer !

The problem is that you missed the implementation of the destructor. You can solve just by defining TemplatePlugin::~TemplatePlugin(){} on your TemplatePlugin.cpp.

I've discovered this by running c++filt _ZN19rqt_template_plugin14TemplatePluginD1Ev that give us the following output: rqt_template_plugin::TemplatePlugin::~TemplatePlugin().

I've created a video ( https://youtu.be/4xZKflNlJho ) that shows that this was the only problem.

Ruben.

edit flag offensive delete link more

Comments

Awesome! That was it! Thanks for spotting this!

Femer gravatar image Femer  ( 2017-11-28 08:35:37 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-11-24 10:03:42 -0500

Seen: 1,344 times

Last updated: Nov 28 '17