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

Eigen compilation issue #940

Closed
ghost opened this issue Nov 25, 2021 · 15 comments · Fixed by #944
Closed

Eigen compilation issue #940

ghost opened this issue Nov 25, 2021 · 15 comments · Fixed by #944

Comments

@ghost
Copy link

ghost commented Nov 25, 2021

Description

When compiling on Ubuntu 21.10 after installing dependencies through apt, the project fails to compile
(I have attached the output of make check here: gtsamMakeCheckLog.txt)

Steps to reproduce

  1. Install dependencies via apt on Ubuntu 21.10
  2. Attempt to build

Expected behavior

The library is expected to compile

Environment

I am using Ubuntu 21.10, gcc 11.2.0, cmake 3.18.4, boost 1.74, and the develop branch

Additional information

This issue has already been mentioned in this pull request, but the patch mentioned is no longer available
#391 (comment)

@jlblancoc
Copy link
Member

Could you show the full command line of the failing file? i.e. the last big fat line when doing VERBOSE=1 make -j1

@ghost
Copy link
Author

ghost commented Nov 25, 2021

cd /home/quincy/Documents/LinuxVR/gtsam/build/gtsam && /usr/bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_CHRONO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_REGEX_DYN_LINK -DBOOST_SERIALIZATION_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_TIMER_DYN_LINK -DNDEBUG -Dgtsam_EXPORTS -I/home/quincy/Documents/LinuxVR/gtsam -I/home/quincy/Documents/LinuxVR/gtsam/build -I/home/quincy/Documents/LinuxVR/gtsam/CppUnitLite -I/home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/Eigen -I/home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/metis/include -I/home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/metis/libmetis -I/home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/metis/GKlib -isystem /home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/SuiteSparse_config -isystem /home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/Spectra -isystem /home/quincy/Documents/LinuxVR/gtsam/gtsam/3rdparty/CCOLAMD/Include -O3 -DNDEBUG -fPIC -march=native -Wall -fPIC -Wreturn-local-addr -Werror=return-local-addr -Wreturn-type -Werror=return-type -Wformat -Werror=format-security -Wsuggest-override -O3 -Wno-unused-local-typedefs -o CMakeFiles/gtsam.dir/navigation/CombinedImuFactor.cpp.o -c /home/quincy/Documents/LinuxVR/gtsam/gtsam/navigation/CombinedImuFactor.cpp

@ghost
Copy link
Author

ghost commented Nov 25, 2021

The comment on the pull request I mentioned earlier (this: #391 (comment)) said that this issue was only with c++17, so I ran the compile command I commented earlier with an added -std=c++11 to compile only that file in c++11, and because make checks for object files before attempting to compile, I managed to get the library to build.

@jlblancoc
Copy link
Member

jlblancoc commented Nov 28, 2021

Ah! It must be a new issue with g++11.2
Perhaps g++11 should be added to the CI build matrix?

From here:

GCC 11 Now Defaults To C++17 Dialect By Default

So this is gonna become a real issue for most users if they get the latest g++ but not the latest Eigen3...
An ugly workaround might be a special build flag for the affected file(s) (via cmake source file properties), or wait for the move to c++17.

@varunagrawal
Copy link
Collaborator

Oh I encountered this exact issue and have proposed a fix to it here #944
This is indeed an issue with GCC 8+.

@varunagrawal varunagrawal linked a pull request Nov 29, 2021 that will close this issue
@ProfFan
Copy link
Collaborator

ProfFan commented Nov 29, 2021

There is a catch here: most people will use system Eigen which is not 3.3.9. I would suggest we do some kind of work-around in our code instead.

@varunagrawal
Copy link
Collaborator

The workaround isn't something we can do trivially. We can use CMake to force 3.3.9 and this shouldn't be a major issue since it is a patch version update.

@ProfFan
Copy link
Collaborator

ProfFan commented Nov 29, 2021

@varunagrawal it is easy to do: https://github.com/humanoid-path-planner/hpp-fcl/pull/226/files

@varunagrawal
Copy link
Collaborator

Cool! I still think we should update eigen since there are other big fixes that we can benefit from.

Asking users to update eigen is a small task for the rewards.

@dellaert
Copy link
Member

@varunagrawal upgrading system eigen is not trivial so I vote to work-around in our code. Please update PR #944 with other reasons to upgrade. Please do not merge until serialization is validated with old Eigen version.

@varunagrawal
Copy link
Collaborator

Okay, I am updating #944 with the workaround that Fan linked.

@varunagrawal
Copy link
Collaborator

Huh @ProfFan that fix doesn't work. I am getting the error

In file included from /usr/local/include/gtsam/base/serializationTestHelpers.h:26,
                 from /home/varun/borglab/GTDynamics/tests/testHelicalJoint.cpp:17:
/usr/local/include/gtsam/base/serialization.h:49:19: error: ‘traits’ is not a class template
   49 | template<> struct traits<boost::serialization::U> {enum {Flags=0};};
      |                   ^~~~~~
/usr/local/include/gtsam/base/serialization.h:49:51: error: explicit specialization of non-template ‘Eigen::internal::traits’
   49 | template<> struct traits<boost::serialization::U> {enum {Flags=0};};
      |                                                   ^

@varunagrawal
Copy link
Collaborator

Also, maintainers of Eigen also call it an "ugly hack" https://gitlab.com/libeigen/eigen/-/issues/1676#note_709679901

@varunagrawal
Copy link
Collaborator

Let me take a closer look at this.

@varunagrawal
Copy link
Collaborator

Figured it out. We need to include Eigen/Core as well. This was mentioned in the original SO answer and not in the PR.

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.

4 participants