0
$\begingroup$

Rosanswers logo

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>

Originally posted by beginner on ROS Answers with karma: 83 on 2015-05-05

Post score: 0


Original comments

Comment by Dirk Thomas on 2015-05-05:
Sharing your code might help others to help you.

Comment by beginner on 2015-05-05:
Added code in the edit... I really hope that someone can help!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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...


Originally posted by Wolf with karma: 7555 on 2015-05-06

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by beginner on 2015-05-06:
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)

Comment by Wolf on 2015-05-06:
check all function signatures are identical, and of cource make sure your new cpp file is amongst ${rqt_my_gui_SRCS}

Comment by beginner on 2015-05-06:
checked, but still not working :(

Comment by Wolf on 2015-05-06:
can you post the code of your cpp files and header?

Comment by beginner on 2015-05-06:
Thanks... I figured it out :D It was a missing definition for a class method which I wasn't using... ughhhhh

Comment by ivaughn_whoi on 2019-12-27:
Anyone have better advice on how to get ANY detail on the linker errors? I just get "could not load plugin", even though the library definitely exists.

You can check for missing symbols with ldd -r devel/lib/<your_library_here>.so, but it would be lovely if there was a way to ask pluginlib to dump debug info.

$\endgroup$

Your Answer

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