include of any Eigen 3.3.1 files in fresh Visual Studio project won't compile

HateDread

I created a fresh C++ (empty) project in VS2015, and then placed the Eigen 3.3.1 source code in an 'inc' folder in solution dir, such that the path to Matrix.h, for example, is inc/Eigen/Core/. I have set this inc/ path as an additional include directory, and have also tried with inc/Eigen/ as another include directory in case the files had issues including each other, but this changed nothing.

In main.cpp, I have the following:

#include "Eigen/Core/Matrix.h"

int main()
{
    return 0;
}

This gives me, when compiling for x64:

1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2988: unrecognizable template declaration/definition
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(18): error C2059: syntax error: '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2143: syntax error: missing ';' before '{'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(19): error C2447: '{': missing function header (old-style formal list?)
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(179): error C2143: syntax error: missing ',' before '<'
1>  c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(404): note: see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols>' being compiled
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2143: syntax error: missing ';' before '<'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(186): error C2238: unexpected token(s) preceding ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C2144: syntax error: 'int' should be preceded by ';'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): warning C4183: 'EIGEN_DENSE_PUBLIC_INTERFACE': missing return type; assumed to be a member function returning 'int'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(192): error C3646: 'PlainObject': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(194): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(195): error C2653: 'Base': is not a class or namespace name
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'EIGEN_STRONG_INLINE': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C3646: 'Matrix': unknown override specifier
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C2143: syntax error: missing ';' before '&'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(206): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(207): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(223): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(237): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(243): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(259): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:\users\brody\documents\visual studio 2015\projects\eigentest\inc\eigen\core\matrix.h(14): fatal error C1075: the left brace '{' was unmatched at the end of the file

Which complains about line 18 of Matrix.h:

#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H

namespace Eigen {

namespace internal {
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > // line 18
{
private:
// etc...

Similar issues occur with any other Eigen #include. Have I missed some required #include ordering or some compile flag or setting? Thanks!

chtz

You must copy the entire Eigen directory not just the src subfolder. And you must not include files from the src subfolder directly, but include the files in the Eigen directory. E.g., #include <Eigen/Core> will include all core functionality, #include <Eigen/Dense> will include all dense functionality (this includes Core, Geometry and the decompositions).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Visual Studio 2013 update 3, Designer won't load

Visual Studio 2012 doesn't load any project

Why can't I compile Apache Cordova project in Visual Studio?

Unsafe code won't compile on Visual Studio 2015

Multiple project visual studio solution won't debug one project dll

FragmentTransaction won't Compile in Kotlin Android Project

Visual Studio won't compile Xamarin IOS Could not locate SDK bin directory

Visual Studio Won't Deploy Project On Android Emulator

Visual Studio for Mac couldn't open any files in any solution

std::unique_ptr works in GCC but won't compile in Visual Studio

Automatic include files in folder in Visual Studio 2019 project

Visual Studio Code won't compile or submit USQL script

How to include OpenGLES 3 in Visual Studio (Android)

Node won't install on a fresh project

.db file won't open on Visual Studio Code using sqlite3

C++ Primer Chapter 14 readStr example won't compile in Visual Studio 2019

In Visual Studio, I don't want to commit my Debug folder, but it has the dll file in it, and if I move it project won't compile

project reference won't compile 'should be reference'

Is there any way to restore visual studio files of a project?

DB Project won't load in Visual Studio 2013

CMake generated Xcode project won't compile

SCSS @include mixin won't compile in Rails

Swift 3 Collection subclass won't compile

Visual Studio stopped recognizing any include files

Visual Studio 2017 won't create C# and Visual Basic project

My C++ program won't compile on Visual Studio code

C header files missing in Visual studio Command prompt to compile Sqlite3.c

Typsescript not working in fresh Vue3 project

Compile Eigen C++ with Intel MKL in visual studio 2022