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

Revision history [back]

click to hide/show revision 1
initial version

I just stumbled across this error as well (while porting rviz to qt5) and will note the answer here for documentation purposes.

So the error you got from pluginloader tells you that your plugin shared object (.so) is not linked to everything it expects. This is because moc, the Meta Object Compiler is used by Qt to create some meta information about what classes, functions, signals, slots exist. moc reads header files searching for classes with the Q_OBJECT macro (short version ;) ). It then outputs a new cpp code file containing this information. This file has to be compiled and linked into your plugin.

The traditional way is what gvdhoorn wrote, the more modern way would be to add

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

and you are done (works for qt4 and qt5).

If some errors remain, it might be because automoc is not perfect. It then helps to just add the header file to the sources list

Writing rviz plugins in Qt5 and loading them in a rviz that was compiled with Qt4 does not work. Neither does the other way around. But the code should be almost the same, so you can just recompile once rviz got ported to qt5