borglab/gtsam

GTSAM was built against a different version of Eigen

FedericoRollo opened this issue · 12 comments

Description

Hi, I'm trying to use this library for 3D slam application but I receive the following error when compiling my packages:

In file included from /usr/local/include/gtsam/base/Matrix.h:28,
                 from /usr/local/include/gtsam/base/Manifold.h:22,
                 from /usr/local/include/gtsam/geometry/BearingRange.h:21,
                 from /usr/local/include/gtsam/geometry/Pose3.h:22:
/usr/local/include/gtsam/base/Vector.h:75:52: error: static assertion failed: Error: GTSAM was built against a different version of Eigen
   75 |     GTSAM_EIGEN_VERSION_WORLD==EIGEN_WORLD_VERSION &&

I've seen that this is an old issue solved in past (e.g. #1304 ) and I tried to build the Gtsam package using -DGTSAM_USE_SYSTEM_EIGEN=ON but the problem persists. During the building process, it seems to find the right Eigen version (3.4.0) installed on the system but it behaves in the same way.

Steps to reproduce

I'm building & installing Gtsam using cmake -DGTSAM_USE_SYSTEM_EIGEN=ON .. and sudo make install

Expected behavior

Environment

Ubuntu 20, C++, Eigen 3.4.0.
Gtsam (developer branch - commit 448132a)

Additional information

Are you building along with another package?

No I'm building and installing it alone using the standard CMake procedure (as shown in the above comment). Moreover if I print the Eigen version while compiling it seems to find the right one 3.4.0...

Then I import it using catkin in another package:

find(gtsam REQUIRED)
.
.
.
.
target_link_library(MY_LIBRARY gtsam)

During the compilation of MY_PACKAGE it fails giving back that error message of the Eigen version misalignment.

I am facing the same problem as you, may I ask if you have solved it?

This question has really been bothering me for a long time

No, I'm stuck in the same situation.

Hi, I think I know how to fix it. You switch to a lower version of GTSAM, I switched to 4.02, then

Find in the CMakeLists.txt file of gtsam:

if(GTSAM_USE_SYSTEM_EIGEN)
     find_package(Eigen3 REQUIRED)
     ...

Add a sentence above if(GTSAM_USE_SYSTEM_EIGEN):

set(GTSAM_USE_SYSTEM_EIGEN ON)

My English is not very good, I don't know if you can understand it

Hi @sinianzuishuai, the passages are clear. I'll try as soon as I can, thank you!

@FedericoRollo check the output of CMake for both GTSAM compilation and compilation of your package. Print out the Eigen version in both, you should hopefully see a mismatch. At that point it is up to you to ensure that the same Eigen version is being used consistently, and this can be done nicely via CMake.

@FedericoRollo any updates on this?

I Varaun, I'm compiling with the same version (3.4.0) but when I run some catkin tests on my package the assertion fails.
I tried different things but the problem persists. I'm probably missing something when I include gtsam in my project.

here is how I declare tests in CMakeLists.txt

if (CATKIN_ENABLE_TESTING)

  include_directories(
    tests/include
  )

  catkin_add_gtest(${PROJECT_NAME}_test 
    tests/core_test.cpp
  )

  target_link_libraries(${PROJECT_NAME}_test
    ${catkin_LIBRARIES}
    gtsam
  )
endif()

find_package(GTSAM REQUIRED) is at the top of the CMakeLists.txt

Moreover, when I try to print the eigen world version during compilation with

message("EIGEN_WORLD_VERSION: ${EIGEN_WORLD_VERSION}")
message("GTSAM_EIGEN_WORLD_VERSION: ${GTSAM_EIGEN_VERSION_WORLD}")

GTSAM_EIGEN_VERSION_WORLD is empty but it could be that it is not loaded yet.

The strange thing is that the whole project does compile (catkin build) without any error but the tests (catkin test) don't.

I finally solved the issue! I downgraded my Eigen version from 3.4 to 3.3.7.
I had two different versions of Eigen installed on my computer and uninstalling 3.4 worked!

Thanks for your support!