0
$\begingroup$

Rosanswers logo

Hello everyone!

I try to create a qt based gui for my package. Therefore I tried to follow the qt tutorials, but get undefined reference errors. I use an eclipse workspace, which shows the qt_gui_cpp:: functions in the auto complete scheme. Therefore I think it is a problem of definition of the plugin. The errors are:

CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function Gui::MyPlugin::initPlugin(qt_gui_cpp::PluginContext&): Catkin/src/Project/src/Gui/gui.cpp:24: undefined reference to qt_gui_cpp::PluginContext::argv() const' Catkin/src/Project/src/Gui/gui.cpp:30: undefined reference to qt_gui_cpp::PluginContext::addWidget(QWidget*)' CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function rqt_gui_cpp::Plugin::Plugin()': /opt/ros/indigo/include/rqt_gui_cpp/plugin.h:57: undefined reference to nodelet::Nodelet::Nodelet()' CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function rqt_gui_cpp::Plugin::~Plugin()': /opt/ros/indigo/include/rqt_gui_cpp/plugin.h:49: undefined reference to nodelet::Nodelet::~Nodelet()' CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function void class_loader::class_loader_private::registerPlugin<Gui::MyPlugin, rqt_gui_cpp::Plugin>(std::string const&, std::string const&)':

In /opt/ros/indigo/include/class_loader/class_loader_core.h I get the undefined reference class_loader::class_loader_private::getCurrentlyLoadingLibraryName()' class_loader::class_loader_private::getCurrentlyActiveClassLoader()' class_loader::class_loader_private::getCurrentlyActiveClassLoader()' class_loader::class_loader_private::hasANonPurePluginLibraryBeenOpened(bool)' class_loader::class_loader_private::getCurrentlyActiveClassLoader()' class_loader::class_loader_private::AbstractMetaObjectBase::addOwningClassLoader(class_loader::ClassLoader*)' class_loader::class_loader_private::getCurrentlyLoadingLibraryName()' class_loader::class_loader_private::AbstractMetaObjectBase::setAssociatedLibraryPath(std::string)' undefined reference to class_loader::class_loader_private::getPluginBaseToFactoryMapMapMutex()' undefined reference to class_loader::class_loader_private::getPluginBaseToFactoryMapMapMutex()'

CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function std::map<std::string, class_loader::class_loader_private::AbstractMetaObjectBase*, std::less<std::string>, std::allocator<std::pair<std::string const, class_loader::class_loader_private::AbstractMetaObjectBase*> > >& class_loader::class_loader_private::getFactoryMapForBaseClass<rqt_gui_cpp::Plugin>()': /opt/ros/indigo/include/class_loader/class_loader_core.h:124: undefined reference to class_loader::class_loader_private::getFactoryMapForBaseClass(std::string const&)'

CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o: In function class_loader::class_loader_private::AbstractMetaObject<rqt_gui_cpp::Plugin>::AbstractMetaObject(std::string const&, std::string const&)': /opt/ros/indigo/include/class_loader/meta_object.h:150: undefined reference to class_loader::class_loader_private::AbstractMetaObjectBase::AbstractMetaObjectBase(std::string const&, std::string const&)' /opt/ros/indigo/include/class_loader/meta_object.h:150: undefined reference to `class_loader::class_loader_private::AbstractMetaObjectBase::~AbstractMetaObjectBase()'

CMakeFiles/Project_node.dir/src/Gui/gui.cpp.o:(.rodata._ZTIN11rqt_gui_cpp6PluginE[_ZTIN11rqt_gui_cpp6PluginE]+0x28): undefined reference to `typeinfo for nodelet::Nodelet'

Unfortunately I cannot resolve the mentioned Functions. Does anyone of you have an idea, how to solve this issue? Thanks a lot in advance!!!

A simplified system setup is given in the following:

My package has the following order:

Catkin/src/Project/
 - src/System/
      -system.cpp     --> Contains int main()
      -system.h 
 - src/Gui/
      -gui.cpp 
      -gui.h 
      -gui.ui
 - CMakeLists.txt
 - package.xml
 - plugin.xml

with CMakeLists:

cmake_minimum_required(VERSION 2.8)
add_definitions(-std=c++11)

project(Project)
find_package(Boost)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation rosbag)
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})

add_message_files(  FILES  messages.msg)        
generate_messages(  DEPENDENCIES  std_msgs) 

catkin_package(
    INCLUDE_DIRS include
    CATKIN_DEPENDS roscpp rospy std_msgs rosbag message_runtime 
    CATKIN_DEPENDS message_runtime
    DEPENDS Boost
)
QT4_WRAP_CPP(MOC_SRC_H  src/Gui/gui.h)
QT4_WRAP_UI(MOC_GUI_H   src/Gui/gui.ui)

include_directories(include 
        ${CMAKE_CURRENT_BINARY_DIR}
        ${Boost_INCLUDE_DIRS} 
        ${catkin_INCLUDE_DIRS}
        /include
        /Project/include
        src/System
        src/Gui
)
add_executable(project_node 
    src/System/system.cpp
    src/Gui/gui.cpp     
    ${MOC_SRC_H} 
    ${MOC_GUI_H}
)       
target_link_libraries(project_node 
    ${catkin_LIBRARIES} 
    ${Boost_LIBRARIES} 
    ${QT_QTCORE_LIBRARY} 
    ${QT_QTGUI_LIBRARY}
)
install(TARGETS project_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

package.xml:

<package>
  <!-- Package Metadata -->
  <name>Project</name>
  <version>1.0.0</version>
  <description>
       Package by JanOor
  </description>
  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>std_msgs</build_depend>
  <run_depend>std_msgs</run_depend>  
  <build_depend>rospy</build_depend>
  <run_depend>rospy</run_depend>
  <build_depend>roscpp</build_depend>
  <run_depend>roscpp</run_depend>
  <build_depend>rqt_gui</build_depend>
  <build_depend>rqt_gui_cpp</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <run_depend>rqt_gui</run_depend>
  <run_depend>rqt_gui_cpp</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <build_depend>rosbag</build_depend>
  <run_depend>rosbag</run_depend>
  <build_depend>message_generation</build_depend>
  <run_depend>message_runtime</run_depend>

  <!-- export documentation -->
<export>
  <rosdoc config="rosdoc.yaml" />
  <rqt_gui plugin="${prefix}/plugin.xml"/>
</export>

</package>

plugin.xml:

<library path="lib/librqt_Project">
  <class name="MyPlugin" type="Gui::MyPlugin" base_class_type="rqt_gui_cpp::Plugin">
    <description>
      An example C++ GUI plugin to create a great user interface.
    </description>
    <qtgui>
      <label>My first C++ Plugin</label>
      <icon type="theme">image-x-generic</icon>
      <statustip>User Interface.</statustip>
    </qtgui>
  </class>
</library>

Gui/gui.h

#ifndef  GUI_H_
#define GUI_H_

#include <rqt_gui_cpp/plugin.h>
#include <ui_gui.h>
#include <QWidget>

namespace Gui {

class MyPlugin: public rqt_gui_cpp::Plugin {
    Q_OBJECT
public:
    MyPlugin();
    virtual void initPlugin(qt_gui_cpp::PluginContext& context);
    virtual void shutdownPlugin();
    virtual void saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const;
    virtual void restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings);
private:
    Ui::MyPluginWidget ui_;
    QWidget* widget_;
};
} // namespace
#endif 

Gui/gui.cpp

#include "gui.h"
#include <pluginlib/class_list_macros.h>
#include <QStringList>

namespace Gui {

MyPlugin::MyPlugin(): rqt_gui_cpp::Plugin(), widget_(0)
{
    // Constructor is called first before initPlugin function, needless to say.
    // give QObjects reasonable names
    setObjectName("MyPlugin");
}

void MyPlugin::initPlugin(qt_gui_cpp::PluginContext& context){
        // access standalone command line arguments
        QStringList argv = context.argv();
        // create QWidget
        widget_ = new QWidget();
        // extend the widget with all attributes and children from UI file
        ui_.setupUi(widget_);
        // add widget to the user interface
        context.addWidget(widget_);
    }
    
    void MyPlugin::shutdownPlugin(){}
    
    void MyPlugin::saveSettings(qt_gui_cpp::Settings& plugin_settings, qt_gui_cpp::Settings& instance_settings) const{}
    
    void MyPlugin::restoreSettings(const qt_gui_cpp::Settings& plugin_settings, const qt_gui_cpp::Settings& instance_settings){}
    } // namespace
    PLUGINLIB_DECLARE_CLASS(Gui, MyPlugin, Gui::MyPlugin, rqt_gui_cpp::Plugin)

Originally posted by JanOr on ROS Answers with karma: 170 on 2016-02-01

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

add rqt_gui_cpp and rqt_gui to the find_package(catkin REQUIRED COMPONENTS ... in CMakeLists.txt


Originally posted by Wolf with karma: 7555 on 2016-02-02

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by JanOr on 2016-02-02:
Oh dear, thanks a lot!

$\endgroup$

Your Answer

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