Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot link due to undefined class_loader symbols #32

Open
KenYN opened this issue Aug 21, 2020 · 5 comments
Open

Cannot link due to undefined class_loader symbols #32

KenYN opened this issue Aug 21, 2020 · 5 comments
Labels

Comments

@KenYN
Copy link

KenYN commented Aug 21, 2020

I think this is a separate issue from #29 although it was initially reported under there. I get the following errors:

Starting >>> rosbag2_bag_v2_plugins
--- stderr: rosbag2_bag_v2_plugins                                
/opt/ros/noetic/lib/librviz.so: undefined reference to `class_loader::MultiLibraryClassLoader::getAllAvailableClassLoaders()'
/opt/ros/noetic/lib/librviz.so: undefined reference to `class_loader::impl::AbstractMetaObjectBase::isOwnedBy(class_loader::ClassLoader const*)'
/opt/ros/noetic/lib/librviz.so: undefined reference to `class_loader::MultiLibraryClassLoader::getRegisteredLibraries[abi:cxx11]()'
/opt/ros/noetic/lib/librviz.so: undefined reference to `class_loader::ClassLoader::isLibraryLoaded()'
/opt/ros/noetic/lib/librviz.so: undefined reference to `class_loader::systemLibrarySuffix[abi:cxx11]()'
collect2: error: ld returned 1 exit status
make[2]: *** [test_rosbag_v2_storage] Error 1
make[1]: *** [CMakeFiles/test_rosbag_v2_storage.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/test_rosbag_output_stream.dir/all] Error 2
make: *** [all] Error 2

Looking at the two libclass_loader.so I see this (and all other methods are const in foxy):

docker@PC:/opt/ros$ nm -C noetic/lib/libclass_loader.so  | grep "class_loader::systemLibrarySuffix"
000000000000ed00 T class_loader::systemLibrarySuffix[abi:cxx11]()
docker@PC:/opt/ros$ nm -C foxy/lib/libclass_loader.so  | grep "class_loader::systemLibrarySuffix"
docker@PC:/opt/ros$

So, the linker should be pulling in noetic/lib/libclass_loader.so but for some reason it is choosing the foxy version. I believe I am sourcing everything correctly:

source /opt/ros/noetic/setup.bash
source ../ros1/install/setup.bash
source ./install/setup.bash
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to rosbag2_bag_v2_plugins --symlink-install

I'm not sure why librviz.so is being picked up - is this normal?

@KenYN
Copy link
Author

KenYN commented Aug 21, 2020

OK, I've added a workaround similar to the nodelet one; in the CMakeLists.txt:

if((NOT "${ros1_message_package}" STREQUAL "nodelet") AND (NOT "${ros1_message_package}" STREQUAL "rviz"))

I still get the "Cannot generate a safe runtime search path for target rosbag2_bag_v2_plugins because there is a cycle in the constraint graph" warning, but otherwise it seems to be OK. ros2 bag info -s rosbag_v2 <path_to_bagfile> works as expected.

@zygfrydw
Copy link

Could you provide more details for your workaround?
Which CMakeList.txt did you modify?
Did you modify src/rosbag2_bag_v2/rosbag2_bag_v2_plugins/CMakeLists.txt?
Did you wrap the entire file with

if((NOT "${ros1_message_package}" STREQUAL "nodelet") AND (NOT "${ros1_message_package}" STREQUAL "rviz"))

I am trying to build this plugin with eloquent and melodic and I get

CMake Warning at CMakeLists.txt:76 (add_library):
  Cannot generate a safe runtime search path for target
  rosbag2_bag_v2_plugins because there is a cycle in the constraint graph:

    dir 0 is [/home/zwieszok/projects/my_rosbag2/install/lib]
    dir 1 is [/opt/ros/eloquent/lib]
      dir 0 must precede it due to runtime library [libros1_rosbag_storage.so]
      dir 3 must precede it due to runtime library [libcv_bridge.so]
    dir 2 is [/opt/ros/eloquent/opt/yaml_cpp_vendor/lib]
    dir 3 is [/opt/ros/melodic/lib]
      dir 1 must precede it due to runtime library [libclass_loader.so]
    dir 4 is [/usr/lib/x86_64-linux-gnu/hdf5/openmpi]
    dir 5 is [/usr/lib/x86_64-linux-gnu/openmpi/lib]

  Some of these libraries may not be found correctly.


/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::impl::AbstractMetaObjectBase::isOwnedBy(class_loader::ClassLoader const*)'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::MultiLibraryClassLoader::getAllAvailableClassLoaders()'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::MultiLibraryClassLoader::getRegisteredLibraries[abi:cxx11]()'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::ClassLoader::isLibraryLoaded()'
collect2: error: ld returned 1 exit status
make[2]: *** [test_rosbag_output_stream] Error 1
make[1]: *** [CMakeFiles/test_rosbag_output_stream.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::impl::AbstractMetaObjectBase::isOwnedBy(class_loader::ClassLoader const*)'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::MultiLibraryClassLoader::getAllAvailableClassLoaders()'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::MultiLibraryClassLoader::getRegisteredLibraries[abi:cxx11]()'
/opt/ros/melodic/lib/librosbag_storage.so: undefined reference to `class_loader::ClassLoader::isLibraryLoaded()'
collect2: error: ld returned 1 exit status
make[2]: *** [test_rosbag_v2_storage] Error 1
make[1]: *** [CMakeFiles/test_rosbag_v2_storage.dir/all] Error 2
make: *** [all] Error 2
---
Failed   <<< rosbag2_bag_v2_plugins [50.1s, exited with code 2]

@KenYN
Copy link
Author

KenYN commented Aug 26, 2020

I replaced this line with the indicated code. In your case, it seems to be rosbag_storage that is causing the problem, so it could be changed to this:

if((NOT "${ros1_message_package}" STREQUAL "nodelet") AND (NOT "${ros1_message_package}" STREQUAL "rosbag_storage")  
               AND (NOT "${ros1_message_package}" STREQUAL "rviz"))

Or perhaps it would be better and more compact as (not tested!):

set(ignore_packages nodelet rosbag_storage rviz)
if (NOT(${ros1_message_package} IN_LIST ignore_packages))

@zygfrydw
Copy link

It works! Thank you 👍 I still get the errors with graph cycles as you described, but it compiles nevertheless.

@adithyab94
Copy link

What worked for me:

colcon build --packages-select rosbag2_bag_v2_plugins --cmake-args ' -Dclass_loader_INCLUDE_DIRS=/opt/ros/foxy/include/class_loader' '-Dclass_loader_LIBRARIES=/opt/ros/foxy/lib/libclass_loader.so'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants