Ask Your Question
0

Failed to add library to rqt plugin

asked 2015-05-05 12:07:37 -0500

beginner gravatar image

updated 2015-05-05 15:18:18 -0500

I have recently written an rqt plugin gui in C++ based on the rqt_image_view plugin.

Everything was working fine until I decided to add another C++ file to my project. This file contains basically a set of useful functions and classes.

After adding it as a library in the CMakeLists.txt, catkin_make is working fine and I am getting no build error.

Moreover, as long as I don't use any functionality from that source file, my plugin loads and works fine. And even if I use stuff from the associated header file, still the plugin loads and works fine.

The issue happens when I actually use that source file in my plugin code. What happens is that although everything still builds, the plugin simply refuses to load, and I get this error message:

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

I am guessing that it might be related to the plugin.xml since there I specify the library path to be that of the gui only. Should I maybe add the path of the library related to my source file? how to do that?

Note that I currently have 2 add_library statement in my CMakeLists.txt: one for the gui and one for the added source file. If I add both of them in one add_library statement, the plugin fails to load even if I don't use the code from the additional source file.

EDIT

This is the relevant part of my CMakeLists.txt:

add_library(helperLib src/additionalSourceFile.cpp)
include_directories(${rqt_my_gui_INCLUDE_DIRECTORIES} ${catkin_INCLUDE_DIRS})
add_library(${PROJECT_NAME} ${rqt_my_gui_SRCS} ${rqt_my_gui_MOCS} ${rqt_my_gui_UIS_H})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} helperLib)

And the plugin.xml: (I am guessing the 1st line should be modified in some way to include the other helper library path)

<library path="lib/librqt_my_gui">
   <class name="myGUI" type="rqt_my_gui::myGUI" base_class_type="rqt_gui_cpp::Plugin">
    <description>
      A GUI plugin
    </description>
    <qtgui>
      <group>
        <label>Robot Tools</label>
      </group>
      <label>My GUI</label>
      <icon type="theme">applications-other</icon>
      <statustip>User interface to allow interaction.</statustip>
    </qtgui>
    </class>
 </library>
edit retag flag offensive close merge delete

Comments

Sharing your code might help others to help you.

Dirk Thomas gravatar imageDirk Thomas ( 2015-05-05 12:28:13 -0500 )edit

Added code in the edit... I really hope that someone can help!

beginner gravatar imagebeginner ( 2015-05-05 15:19:14 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-06 02:29:21 -0500

Wolf gravatar image

This error does not necessarily mean that rqt failed to find and load your library file. If you are saying

Everything was working fine until I decided to add another C++ file to my project.

the lib itself is most likely found but there are some issues when loading the classes/functions in it. A very common mistake that causes this behaviour is declaring (and using) a function that is not defined (implemented); or function declaration and definition do not match. When creating an exec this would cause a linking error but as you are just creating a lib in your project (that is loaded outside your project) the linker will assume that undefined references will be resolve somewhere else when creating the lib. So always double-check all function definitions are declared and definitions and declaration match...

edit flag offensive delete link more

Comments

Apparently, you are right! I tried using a simple source file with simple functions, and everything worked like a charm :) I still need to figure out why my original source file is not working though (it is compiling without errors)

beginner gravatar imagebeginner ( 2015-05-06 03:32:24 -0500 )edit

check all function signatures are identical, and of cource make sure your new cpp file is amongst ${rqt_my_gui_SRCS}

Wolf gravatar imageWolf ( 2015-05-06 04:11:32 -0500 )edit

checked, but still not working :(

beginner gravatar imagebeginner ( 2015-05-06 05:13:44 -0500 )edit

can you post the code of your cpp files and header?

Wolf gravatar imageWolf ( 2015-05-06 05:15:21 -0500 )edit

Thanks... I figured it out :D It was a missing definition for a class method which I wasn't using... ughhhhh

beginner gravatar imagebeginner ( 2015-05-06 07:55:22 -0500 )edit
0

answered 2018-12-05 08:10:27 -0500

Remo gravatar image

I ran into this error recently, even though the code of the plugin has not been touched for a while. What helped me was to clean the .ros folder, it seemed that it contained some corrupt temporary data. Use the following command to do that (but first reassure yourself you do not need any of the contained data):

rm -rf ~/.ros/*
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-05-05 12:07:37 -0500

Seen: 613 times

Last updated: May 06 '15