Ask Your Question
4

rqt plugin undefined symbol

asked 2015-03-31 18:45:31 -0500

oxoocoffee gravatar image

updated 2015-04-01 10:35:49 -0500

l0g1x gravatar image

Hello ALL

I have this strange problem that I encountered while trying to write new plugin. I followed the rqt plugin tutorial and I am able to build. But when starting rqt I can see plugin in Visualization menu. When I click I get this message

[ERROR] [1427841427.537909362]: Failed to load nodelet [gps_plot/GPSPlot_1] of type [gps_plot/GPSPlot]: Failed to load library /home/rob/projects/Test/devel/lib//libgps_plot.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/rob/projects/Test/devel/lib//libgps_plot.so: undefined symbol: _ZTVN8gps_plot9GPSPluginE)
RosPluginlibPluginProvider::load_explicit_type(gps_plot/GPSPlot) failed creating instance
PluginManager._load_plugin() could not load plugin "gps_plot/GPSPlot": RosPluginlibPluginProvider.load() could not load plugin "gps_plot/GPSPlot"

To get started I get one h and one cpp file. For now I commented out all Qt widget_ and ui_ to just build.

Also

ldd /home/rob/projects/Test/devel/lib//libgps_plot.so

does not show any missing libs

From above error I try to grep for strings

~/projects/Test/devel/lib$ strings libgps_plot.so  | grep _ZTVN8gps_plot9GPSPluginE
_ZTVN8gps_plot9GPSPluginE
_ZTVN8gps_plot9GPSPluginE

nm -u libgps_plot.so  | grep _ZTVN8gps_plot9GPSPluginE
U _ZTVN8gps_plot9GPSPluginE

So it is there

c++filt _ZTVN8gps_plot9GPSPluginE shows
vtable for gps_plot::GPSPlugin

I also made sure that I export class at bottom of cpp file

PLUGINLIB_EXPORT_CLASS(gps_plot::GPSPlugin, rqt_gui_cpp::Plugin)

So I am little puzzled by this. Any one knows or had this? I am thinking something is missing in my CMakeList file.

Also in above error there is double "//"before libgps_plot.so. Not sure how to fix this. I dod go over my plugin.xml and package.xml and CMakeLists.txt file over and over and I do not see anything odd.

load library /home/rob/projects/Test/devel/lib//libgps_plot.so

Here is my CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)

project(gps_plot)

find_package(catkin REQUIRED COMPONENTS
    dynamic_reconfigure
    message_generation
    roscpp
    rqt_gui
    rqt_gui_cpp
    sensor_msgs
    std_msgs
)

find_package(Boost REQUIRED COMPONENTS
    program_options
)

find_package(Qt4 REQUIRED COMPONENTS
    QtCore
    QtGui
)

include(${QT_USE_FILE})

set(gps_plot_SRCS
  src/gpsPlugin.cpp
)

set(gps_plot_HDRS
  include/gps_plot/gpsPlugin.h
)

catkin_package(
  INCLUDE_DIRS  ${gps_plot_INCLUDE_DIRECTORIES}
  LIBRARIES     ${PROJECT_NAME}
  CATKIN_DEPENDS dynamic_reconfigure message_generation roscpp rqt_gui rqt_gui_cpp sensor_msgs std_msgs
)

qt4_wrap_ui(
    gps_plot_UIS_H
    ${gps_plot_UIS}
)

include_directories(
    ${Boost_INCLUDE_DIRS}
)

link_directories(
    ${Boost_LIBRARY_DIRS}i
)

include_directories(
    include
    ${catkin_INCLUDE_DIRS}
)

add_library(
    ${PROJECT_NAME}
    ${gps_plot_SRCS}
)

target_link_libraries( 
   ${PROJECT_NAME}
   ${catkin_LIBRARIES}
   ${QT_QTCORE_LIBRARY}
   ${QT_QTGUI_LIBRARY}
   ${Boost_LIBRARIES}
)

find_package(class_loader)
class_loader_hide_library_symbols(${PROJECT_NAME})

install(FILES plugin.xml
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

install(TARGETS ${PROJECT_NAME}
    ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
    RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/
    DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

And my plugin.xml

<library path="lib/libgps_plot">
  <class name="Btest/GPSPlot" type="gps_plot::GPSPlugin" base_class_type="rqt_gui_cpp::Plugin">
    <description>
      Test GPS plotter using nmea_msgs/Sentence and sensor_msgs/NavSatFix messages
    </description>
    <qtgui>
      <group>
        <label>Visualization</label>
        <icon type="theme">folder</icon>
        <statustip>Plugins related to visualization.</statustip>
      </group>
      <label>Test GPS plotter</label>
      <icon type="theme">applications-internet</icon>
      <statustip>Test GPS and status points on an map</statustip>
    </qtgui>
  </class>
</library>
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-04-01 20:12:19 -0500

oxoocoffee gravatar image

Looks like rqt - Writing a C++ Plugin is little incomplete. Since I did commented out all instances of QT ( Ui::MyPluginWidget ui_; QWidget* widget_; ) BUT LEFT Q_OBJECT in MyPlugin class this was the source of the problem. I am intending to update above link in couple of days and clean it up with my finding/corrections/notes. Also will try to add missing C++ UI writeup

edit flag offensive delete link more

Comments

1

Can you expand on why you feel it is incomplete. It's not clear from your answer what exactly is wrong. Please update your answer with changes you make to the wiki.

William gravatar imageWilliam ( 2015-04-01 20:32:41 -0500 )edit
2

answered 2015-04-01 13:37:37 -0500

William gravatar image

The symbol is listed by nm, but as a U which means undefined:

https://sourceware.org/binutils/docs/...

You probably declared the class, but for some reason did not define the class, there for your shared library will be looking for the definition of the class, usually resulting in a T from nm, from another library at link time. This error has likely eluded you because the default behavior for shared libraries on Linux when a symbol is missing at compile time is to assume it is provided at runtime. At runtime the symbol is not there, which is why you have your error.

You can try using the --no-allow-shlib-undefined linker flag to find it at compile time, but you can also just look at your source code and try to figure out the issue. If you post your package on GitHub (or something similar) we can look at it in more detail. Either way, this is likely a C++ problem.

edit flag offensive delete link more
2

answered 2016-04-20 17:37:49 -0500

lucasw gravatar image

updated 2016-04-20 17:39:05 -0500

I had this error then found that my qt4_wrap_cpp() was wrapping my cpp file, and not the header, fixed it and the plugin loaded properly. There isn't a qt4_wrap_cpp above, try adding it- it should wrap any headers that have Q_OBJECT in them.

I made a complete C++ rqt example following the tutorial https://github.com/lucasw/rqt_mypkg/t...

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

4 followers

Stats

Asked: 2015-03-31 18:32:53 -0500

Seen: 1,897 times

Last updated: Apr 20 '16