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

disable new dtags #756

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

SiyuChen1
Copy link

If another version of the g2o library is installed on your computer (e.g., as part of ROS 2) and the ROS 2 environment variables (including LD_LIBRARY_PATH) are sourced, leading to the linker prioritizing the ROS-installed version of the g2o library, even the -Wl, -rpath is specified in the linker. Since many modern linkers, like Ninja or make, use the --enable-new-dtags option by default. When this option is enabled, the -Wl,-rpath flag sets RUNPATH instead of RPATH. Thus, adjust the CMakeLists.txt accordingly.

Ps. When a program is executed, the dynamic linker looks for shared libraries in the following order:

  • RPATH (Runtime Library Search Path)
  • LD_LIBRARY_PATH
  • RUNPATH
  • Default System Directories

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d0f7020) 50.87% compared to head (bec8314) 50.87%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #756   +/-   ##
=======================================
  Coverage   50.87%   50.87%           
=======================================
  Files         271      271           
  Lines       10972    10972           
=======================================
  Hits         5582     5582           
  Misses       5390     5390           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RainerKuemmerle
Copy link
Owner

I am not entirely sure if this is just a workaround to better support having some ROS installation in parallel?
As we see in the CI pipeline, this would also require more changes to support other platforms than Linux where the linker might not support this specific command line flag.

@SiyuChen1
Copy link
Author

Thanks for replying.
Yes, I agree with that it is more like a workaround with ROS2 installation. In my case, since the ROS2 environment variables are been sourced, LD_LIBRARY_PATH will be set by ROS2 automatically. When I tried to build this project, after checking with LDD, I found that the wrong .so files are been linked. For example, libg2o_core.so should have depended on the libg2o_stuff.so which is located in the <build_dir>/lib. However, the library libg2o_stuff.so provided by ROS2 has been linked. Same problems occured for those bins or libs that depends on libg2o_core.so and so on.

As the CI pipeline showed, linker on OSX seems that it doesn't support this flag.

if(NOT APPLE)
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--disable-new-dtags")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--disable-new-dtags")
endif()

It might be a solution to it.

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

Successfully merging this pull request may close these issues.

2 participants