# RQT Custom Plugin: Could not load library: Undefined Symbol

Hello all. I've been using ROS Indigo for about a year now on various projects and finally am starting to experiment with creating custom plugins for RQT. I spent a few days introducing myself to Qt and have now been trying to just get a very simple plugin adapted from Qt to RQT just to see how the process works, working off of the rqt_example_cpp class. When working, the Plugin should produce a QPushButton that, upon being pressed, displays a message to ROS_INFO and changes the text of the button (I was trying to keep this super simple just to understand the process of switching from Qt to RQT).

As far as I can tell I have everything laid out the same as the example, and my code compiles, but when I try to open my plugin (aptly called "test_button") in RQT I get the following error:

[ERROR] [1532309616.004701941]: Failed to load nodelet [rqt_testing/test_button_1] of type [rqt_testing/test_button]: Failed to load library /home/mike/catkin_ws/devel/lib//librqt_testing.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/mike/catkin_ws/devel/lib//librqt_testing.so: undefined symbol: _ZTVN11rqt_testing11test_buttonE)

RosPluginlibPluginProvider::load_explicit_type(rqt_testing/test_button) failed creating instance


When I comment out Q_OBJECT in my code the error goes away and the plugin loads, but then of course I can't utilize slots or signals as I'd like, so the plugin is ultimately useless.

I figure instead of linking the code from a bunch of different files that it would be easier to just post my repository, which I've done here. That being said, I've linked the source, header, and CMakeLists files below in case somebody catches an easy problem in one of those. I would really appreciate if somebody could help me out on this, as I've been smacking my head against a wall for a few days now trying to figure out this problem and have made about zero headway on it. Thanks!

./src/rqt_testing/test_button.cpp

#include "rqt_testing/test_button.h"

#include <pluginlib/class_list_macros.h>
#include <ros/master.h>
#include <QStringList>

namespace rqt_testing {

test_button::test_button()
: rqt_gui_cpp::Plugin()
, widget_(0)
{
setObjectName("test_button");
}

void test_button::initPlugin(qt_gui_cpp::PluginContext& context)
{
QStringList argv = context.argv();

widget_ = new QWidget();
ui_.setupUi(widget_);

//adds number if more than 1 of this plugin?
if (context.serialNumber() > 1)
{
widget_->setWindowTitle(widget_->windowTitle() + " (" + QString::number(context.serialNumber()) + ")");
}

//ui_.image_frame->installEventFilter(this);

connect(ui_.pushButton, SIGNAL(pressed()), this, SLOT(on_pushButton_clicked()));

}

bool test_button::eventFilter (QObject* watched, QEvent* event)
{
return true;
}

void test_button::shutdownPlugin()
{

}

void test_button::on_pushButton_clicked()
{
this->ui_.pushButton->setText("Pressed");
ROS_INFO("Pressed the button");
}

} //namespace rqt_testing

PLUGINLIB_EXPORT_CLASS(rqt_testing::test_button, rqt_gui_cpp::Plugin)


./include/rqt_testing/test_button.h

#ifndef rqt_testing_test_button_H
#define rqt_testing_test_button_H

#include <rqt_gui_cpp/plugin.h>
#include <rqt_testing/ui_test_button.h>

#include <QWidget>
#include <QString>

namespace ...
edit retag close merge delete

Sort by » oldest newest most voted

By default, the linker doesn't check that shared libraries are linked correctly, so it doesn't display much useful information upon failure. You can change that by setting the linker flag:

set(CMAKE_CXX_FLAGS "-Wl,--no-undefined")


Then you should get much more detailed error messages.

more

Did some more debugging after getting some rest. Turns out I had changed some names in my CMakeLists.txt that was causing the MOCS and UIS_H wrappers to not be made, notably the lines

if("${qt_gui_cpp_USE_QT_MAJOR_VERSION} " STREQUAL "5 ") qt5_wrap_cpp(rqt_testing_MOCS${test_button_HDRS})
qt5_wrap_ui(rqt_testing_UIS_H ${test_button_UIS}) else() qt4_wrap_cpp(rqt_testing_MOCS${test_button_HDRS})
qt4_wrap_ui(rqt_testing_UIS_H \${test_button_UIS})
endif()


Changing instances of "test_button" to "rqt_testing" in these lines has allowed for my code to now be working correctly. Amazing what an (almost) full nights rest can do!

more