简体   繁体   中英

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

I took a sample code from their site and I tried to compile with and without the -l option.

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:

I just faced, a difficult to identify, compilation error with 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 :

#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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