简体   繁体   English

使用Eigen库的编译错误

[英]Compilation error using Eigen library

I'm trying to use the Eigen C++ template library for linear algebra, I compiled and installed the library to the following path /usr/local/include 我正在尝试将Eigen C ++模板库用于线性代数,我将该库编译并安装到以下路径/usr/local/include

I took a sample code from their site and I tried to compile with and without the -l option. 我从他们的站点中获取了示例代码,并且尝试使用-l选项进行编译,也可以不使用-l选项进行编译。

g++ -l /usr/local/include/eigen3 test.cpp -o mytest

but I'm getting the following error: 但出现以下错误:

test.cpp:2:23: fatal error: Eigen/Dense: No such file or directory

How can I include this library? 如何包含该库?

您要使用-I选项,而不要使用-l

g++ -I /usr/local/include/eigen3 test.cpp -o mytest

For MSVC users : my two cents specific answer: 对于MSVC用户:两美分的具体答案:

I just faced, a difficult to identify, compilation error with Eigen. 我只是遇到一个难以识别的Eigen编译错误。 It was caused by the procedure describe here - Finding Memory Leaks Using the CRT Library , which consists of overriding the new operator to detect memory leaks with the following macro : 这是由此处描述的过程引起的-使用CRT库查找内存泄漏 ,该过程包括使用以下宏覆盖new运算符以检测内存泄漏:

#ifdef _DEBUG
    #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
#else
    #define DBG_NEW new
#endif

This macro doesn't work with Eigen. 此宏不适用于本征。

As soon as I removed it, the problem was solved. 我一删除它,问题就解决了。

I hope this may help you. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM