Robotics StackExchange | Archived questions

How to resolve undefined symbol referenced from my plugin for ray sensor?

I've created a Gazebo Plugin that inherits from the RayPlugin type.

class CustomPlugin : public RayPlugin

It compiles just fine (using Gazebo 9), but when I launch Gazebo I get the following error.

[Err] [Plugin.hh:180] Failed to load plugin {path_to_plugin}/libcustom_plugin.so: {path_to_plugin}/libcustom_plugin.so: undefined symbol:
_ZTIN6gazebo9RayPluginE

I am referencing it in my model file like this:

   <plugin name="custom_plugin" filename="libcustom_plugin.so">
      <!--Parameters-->
   </plugin>

In my CMakeLists.txt, I am linking like this:

add_library(custom_plugin SHARED plugins/custom_plugin.cpp)
target_link_libraries(custom_plugin ${GAZEBO_LIBRARIES} ${IGNITION-MSGS_LIBRARIES})

I've done two things to ensure that the GAZEBOPLUGINPATH is set correctly. First, I've used the tag in package.xml.

  <export>
    <!-- Other tools can request additional information be placed here -->
    <gazebo_ros plugin_path="${prefix}/lib" gazebo_media_path="${prefix}" gazebo_model_path="${prefix}/models"/>
  </export>

Secondly, I've manually set the variable to reference both the native Gazebo plugins and the lib folder.

export GAZEBO_PLUGIN_PATH=/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:{path_to_ros_package}/devel/lib

I've verified that /usr/lib/x86_64-linux-gnu/gazebo-9/plugins contains libRayPlugin.so. Neither of these two works.

I am at a loss. Any thoughts?

Asked by bybee.taylor on 2018-03-26 14:34:41 UTC

Comments

Answers

Just for reference, I got it working by including the following in the CMakeLists.txt.

link_directories(${GAZEBO_LIBRARY_DIRS})

and

add_library(custom_plugin SHARED plugins/custom_plugin.cpp)
target_link_libraries(custom_plugin RayPlugin ${GAZEBO_LIBRARIES} ${IGNITION-MSGS_LIBRARIES})

Asked by bybee.taylor on 2018-03-26 15:10:15 UTC

Comments

That worked for me also

Asked by adel on 2020-08-19 04:18:42 UTC