Robotics StackExchange | Archived questions

Unresolved symbol OgreVector3::ZERO in rviz tool plugin

I'm learning how to create custom tool plugins for rviz by following the "Plant Flag" tutorial (https://github.com/ros-visualization/visualization_tutorials/blob/groovy-devel/rviz_plugin_tutorials/src/plant_flag_tool.h) in ROS2 FOXY.

I introduced many changes, in particular, I replaced

namespace Ogre {
class SceneNode;
class Vector3;
} 

with

 #include <OgrePrerequisites.h>

But when I load the plugin into rviz, i keep running into the following error message:

LoadLibrary error: /rep/ros2/install/rviz_plugin_tutorials/lib/librviz_plugin_tutorials.so:      
undefined symbol: _ZN4Ogre7Vector34ZEROE

I'm using the version of Ogre provided with the rvizogrevendor package and I'm attaching it by writing

find_package(rviz_ogre_vendor REQUIRED) 

in CMakeLists.txt. I checked that the include directory for OGRE resolves correctly in cmake, however I am unsure about libraries for which there are relative rather than absolute paths:

OgreHLMSOgreMeshLodGeneratorOgreOverlayOgrePagingOgrePropertyOgreRTShaderSystemOgreTerrainOgreVolumeOgreMainPlugin_BSPSceneManagerPlugin_OctreeSceneManagerPlugin_PCZSceneManagerPlugin_ParticleFXRenderSystem_GLRenderSystem_GL3PlusCodec_STBI

but you don't need to link OgreVector, do you ? (OgreVector looks to me a template library, ZERO is declared there as static const and I don't have any occurances of ZERO in my project).

Actually i used to have two copies of OGRE in my machine, one in /usr/include and /usr/share (without libraries) and the second inside rvizogrevendor which were in conflict, so I removed the first one.

Can anyone help me to solve this problem ?

EDITED: I added to CMakeLists.txt the following lines:

target_link_libraries(rviz_plugin_tutorials
  PUBLIC
  Qt5::Widgets
  rviz_ogre_vendor::OgreMain
  rviz_ogre_vendor::OgreOverlay
)

and

ament_export_dependencies(
  Qt5
  rviz_common
  rviz_ogre_vendor
)

It didn't help.

Asked by staskikot on 2021-03-18 12:14:10 UTC

Comments

Answers

Figured it out for my case: replacing the old ROS1-style headers like "OGRE/OgreSceneManager.h" and "OGRE/OgreSceneNode.h" with the ROS2-style "OgreSceneManager.h" and "OgreSceneNode.h" fixed this linking error for me. Hope this helps someone else!

Asked by Helen on 2021-10-11 09:04:27 UTC

Comments