在新的Visual Studio项目中包含任何Eigen 3.3.1文件将无法编译
include of any Eigen 3.3.1 files in fresh Visual Studio project won't compile
我在VS2015中创建了一个新鲜的C (空)项目,然后将eigen 3.3.1源代码放在解决方案dir中的'inc'文件夹中,因此矩阵的路径。例如,H是 inc/eigen/core/。我已经将此 inc/路径设置为附加目录,并且还尝试使用 inc/eigen/em>作为另一个目录,以防这些文件彼此之间有包括彼此的问题,但这一切都没有改变。
在main.cpp中,我有以下内容:
#include "Eigen/Core/Matrix.h"
int main()
{
return 0;
}
这给了我,当x64编译时:
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(18): error C2988: unrecognizable template declaration/definition
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(18): error C2143: syntax error: missing ';' before '<'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(18): error C2059: syntax error: '<'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(19): error C2143: syntax error: missing ';' before '{'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(19): error C2447: '{': missing function header (old-style formal list?)
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(179): error C2143: syntax error: missing ',' before '<'
1> c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(404): note: see reference to class template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols>' being compiled
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(186): error C2143: syntax error: missing ';' before '<'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(186): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(186): error C2238: unexpected token(s) preceding ';'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(192): error C2653: 'Base': is not a class or namespace name
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(192): error C2144: syntax error: 'int' should be preceded by ';'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(192): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(192): warning C4183: 'EIGEN_DENSE_PUBLIC_INTERFACE': missing return type; assumed to be a member function returning 'int'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(192): error C3646: 'PlainObject': unknown override specifier
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(194): error C2653: 'Base': is not a class or namespace name
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(195): error C2653: 'Base': is not a class or namespace name
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(206): error C3646: 'EIGEN_STRONG_INLINE': unknown override specifier
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(206): error C3646: 'Matrix': unknown override specifier
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(206): error C2143: syntax error: missing ';' before '&'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(206): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(207): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(223): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(237): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(243): error C2061: syntax error: identifier 'EIGEN_STRONG_INLINE'
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(259): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
1>c:usersbrodydocumentsvisual studio 2015projectseigentestinceigencorematrix.h(14): fatal error C1075: the left brace '{' was unmatched at the end of the file
抱怨矩阵的第18行:
#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...
任何其他特征#include都会出现类似的问题。我是否错过了一些必需的#include订购或一些编译标志或设置?谢谢!
您必须复制整个Eigen
目录,而不仅仅是src
子文件夹。而且,您不得直接包含src
子文件夹中的文件,而必须在Eigen
目录中包含文件。例如,#include <Eigen/Core>
将包括所有核心功能,#include <Eigen/Dense>
将包括所有密集功能(这包括核心,几何和分解)。
相关文章:
- 使用 Makefile 中的头文件编译 Pybind (不使用 cmake)
- 如何使用命令提示符、记事本和 MinGW 使用主文件、头文件和实现文件编译C++程序?
- 无论如何可以将webm / mp4文件编译/记忆为.exe程序吗?(C++)
- 从生成文件编译错误:"Unable to open output file" ..."No such file or directory"
- 如何使用 GLFW 预编译的二进制文件编译 Visual Studio 2019 发布版本
- Arduino IDE中自定义库类的.h文件编译错误的原因是什么
- makefile和错误将与大型项目分开的文件编译
- 如何使用生成文件编译具有多个目录的 c++ 项目
- 我可以将Visual Studio 2015头文件编译成dll并在VS2013中使用它吗?
- 使用Bazel将C 文件编译为python.h
- 使用 .a 文件编译简单的C++文件
- OpenCV 3.2 文件编译
- 如何从多个 cpp 文件编译 WebAssembly
- 从多个文件编译可以"undefined reference"
- 使用静态依赖性为共享二进制文件编译语法需要更加清晰
- 将Gsoap Src文件编译到我的项目中
- 如何用多个文件编译make下的dlib
- 字段的类型不完整,从多个文件编译
- 强制将特定文件编译为Objective-C/文件类型,但将整个项目编译为Objective C++
- OpenGLES 标头(包括 Availability.h)可防止 CPP 文件编译