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

Compiling on RHEL8 fails #114

Closed
christophfroehlich opened this issue Jan 24, 2024 · 10 comments · Fixed by #125
Closed

Compiling on RHEL8 fails #114

christophfroehlich opened this issue Jan 24, 2024 · 10 comments · Fixed by #125

Comments

@christophfroehlich
Copy link
Contributor

christophfroehlich commented Jan 24, 2024

Hi, it's me again trying to get a CI pipeline for humble@RHEL working.

But there is some issue with Eigen:

Starting >>> rsl     
--- stderr: rsl                         
CMake Error at CMakeLists.txt:25 (target_link_libraries):
  Target "rsl" links to:

    Eigen3::Eigen

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

I was able to fix this by just not link the library but add the include folders: christophfroehlich@8d2bace

I don't have much experience with Eigen, but as it is a header-only library, why should one link against it?

With the released version of Eigen on rhel8 there are a lot of build warnings -> I also had to change the compiler flags.

A newer release of Eigen (3.4 for example) hasn't fixed any of those issues.

@christophfroehlich
Copy link
Contributor Author

What I tried to fix the compiler warnings as "eigen" error: use of old-style cast to ‘int’ [-Werror=old-style-cast]

  • use a latest eigen version
cd /usr/include/eigen3 && rm -rf Eigen unsupported && \
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz && \
tar --strip-components=1 -xzf eigen-3.4.0.tar.gz
  • use a newer c++ compiler (v11 instead of v8)
dnf install gcc-toolset-11
scl enable gcc-toolset-11 bash
colcon build

but all with the same results.

@ChrisThrasher
Copy link
Collaborator

Linking against CMake targets is the canonical way to express dependencies. One of the benefits is that it ensures warnings aren’t applied to Eigen headers as you’re seeing. We would not consider what you proposed.

@christophfroehlich
Copy link
Contributor Author

I see. But apparently, it introduces other issues..
Any suggestions how to fix the original "target not found" error then?

Btw other packages don't do it in the linking-way, e.g., the admittance_controller with origins from PickNik, too. 🤷‍♂️ Do you have any resources for me for best practices on that topic?

@ChrisThrasher
Copy link
Collaborator

https://eigen.tuxfamily.org/dox/TopicCMakeGuide.html

We’re doing exactly what Eigen recommends. Perhaps your OS is too old for your Eigen installation to include this CMake target.

@christophfroehlich
Copy link
Contributor Author

Thanks for the link, maybe I have to set CMAKE_PREFIX_PATH on this platform.

@christophfroehlich
Copy link
Contributor Author

I found some time for trying to fix this.

Default on RHEL8 is eigen 3.3.4 and CMake 3.26

Whatever I tried,

  • running colcon with --cmake-args -DCMAKE_PREFIX_PATH=/usr/local/share/eigen or /usr/local/include/eigen3
  • or installing eigen 3.4.0 with cmake before

--> I always got the same error.

The only thing what fixes the build is add NO_MODULE to find_package (Eigen3 REQUIRED NO_MODULE), like it is written in the official docs linked above.
This works on all platforms like I tested here ros-controls/kinematics_interface#50

Is there any disadvantage? any chance to add this in RSL?

@ChrisThrasher
Copy link
Collaborator

NO_MODULE ensures that Eigen3Config.cmake gets used in lieu of FindEigen3.cmake assuming such a file exists. That’s fine by me. Whatever FindEigen3.cmake module is being found on your machine obviously isn’t sufficient since it does not define the IMPORTED CMake target that Eigen3Config.cmake defines. I think I’m fine with a PR that makes such a change especially if that’s what the docs already recommend.

If I had to guess FindEigen3.cmake is some legacy relic from a time before the library provided a config module. 1st party config modules are always preferable to find modules when available.

@christophfroehlich
Copy link
Contributor Author

Thanks @ChrisThrasher for your help!

@christophfroehlich
Copy link
Contributor Author

Now are other jobs failing using generate_parameter_library with the same error (both are built from source)
https://github.com/ros-controls/control_toolbox/actions/runs/8037264479/job/21951911473#step:7:19

Must this NO_MODULE|CONFIG now also be passed to to find_package(rsl)? And as a consequence also to find_package(generate_parameter_library)?
https://github.com/PickNikRobotics/generate_parameter_library/blob/main/generate_parameter_library/generate_parameter_library-extras.cmake#L32

@ChrisThrasher
Copy link
Collaborator

ChrisThrasher commented Feb 25, 2024

Now are other jobs failing using generate_parameter_library with the same error (both are built from source) https://github.com/ros-controls/control_toolbox/actions/runs/8037264479/job/21951911473#step:7:19

Must this NO_MODULE|CONFIG now also be passed to to find_package(rsl)? And as a consequence also to find_package(generate_parameter_library)? https://github.com/PickNikRobotics/generate_parameter_library/blob/main/generate_parameter_library/generate_parameter_library-extras.cmake#L32

#126

Could you please test this out?

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 a pull request may close this issue.

2 participants