Home > Net >  Error: This compiler appears to be too old to be supported by Eigen
Error: This compiler appears to be too old to be supported by Eigen

Time:04-21

I am trying to compile a project that includes the eigen library and I get this error:

In file included from /home/--/--/--/Eigen/Core:19,
             from /home/--/--/--/Eigen/Geometry:11,
             from /usr/include/rl-0.7.0/rl/math/Transform.h:34,
             from /home/--/--/--/example.cpp:2:
/home/--/--/--/Eigen/src/Core/util/Macros.h:674:2: error: #error This compiler appears to be too old to be supported by Eigen
674 | #error This compiler appears to be too old to be supported by Eigen
  |  ^~~~~

I am using:

  • Ubuntu 20.04
  • Cmake 3.16.3
  • VSCode Compiler GCC 10.3.1
  • Eigen 3.4.90

The problem seems to be related to these lines in Macros.h file:

// The macros EIGEN_HAS_CXX?? defines a rough estimate of available c   features
// but in practice we should not rely on them but rather on the availability of
// individual features as defined later.
// This is why there is no EIGEN_HAS_CXX17.
#if EIGEN_MAX_CPP_VER<14 || EIGEN_COMP_CXXVER<14 || (EIGEN_COMP_MSVC && EIGEN_COMP_MSVC < 1900) || \
   (EIGEN_COMP_ICC && EIGEN_COMP_ICC < 1500) || (EIGEN_COMP_NVCC && EIGEN_COMP_NVCC < 80000) ||     \
   (EIGEN_COMP_CLANG && ((EIGEN_COMP_CLANG<309) || (defined(__apple_build_version__) && (__apple_build_version__ < 9000000)))) || \
   (EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<51)
#error This compiler appears to be too old to be supported by Eigen
#endif

Do you know how to fix this error?

CodePudding user response:

As @Lala5th suggested, by changing the C standard the problem is solved.

I have modified the CMakeLists.txt:

From:

set(CMAKE_CXX_STANDARD 11)

To:

set(CMAKE_CXX_STANDARD 17)

(It also works with 14)

CodePudding user response:

As you've noted, Macros.h file tells us the problem is with compiler version.

VSCode compiler

GCC 10 definitely has support for c 17. It means that you should change it's starting flags. In settings.json file add this lines:

"code-runner.executorMap": {
    "cpp": "cd $dir && g   -std=c  17 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
},

according to this answer.

Standard Bash's g

Use g with -std=c 17 flag.

  • Related