mingw windows找不到Eigen头文件

Posted

技术标签:

【中文标题】mingw windows找不到Eigen头文件【英文标题】:mingw windows can not find Eigen header file 【发布时间】:2016-01-07 02:33:03 【问题描述】:

我无法让 Eigen 开始工作。

根据this link,我必须使用

g++ -I /path/to/eigen/ my_program.cpp -o my_program 

但这对 mingw 不起作用

所以我查看了 mingw doc here。看来我应该将 Eigen 文件夹放入c:/mingw/include。所以我做到了,但仍然没有工作

这里是 C++ 源代码

#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()

  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;

这是 --verbose 的输出

D:\w\WORK\C++program\use eigen>g++ firsteigen.cpp --verbos
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5
.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-5.2.0/configure --host=x86_64-w64-mingw32 --bu
ild=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysr
oot=/c/mingw520/x86_64-520-win32-seh-rt_v4-rev0/mingw64 --with-gxx-include-dir=/
mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable
-multilib --enable-languages=c,c++,fortran,objc,obj-c++,lto --enable-libstdcxx-t
ime=yes --enable-threads=win32 --enable-libgomp --enable-libatomic --enable-lto
--enable-graphite --enable-checking=release --enable-fully-dynamic-string --enab
le-version-specific-runtime-libs --disable-isl-version-check --disable-libstdcxx
-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win3
2-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with
-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib
--with-gmp=/c/mingw520/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mi
ngw520/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw520/prerequisi
tes/x86_64-w64-mingw32-static --with-isl=/c/mingw520/prerequisites/x86_64-w64-mi
ngw32-static --with-pkgversion='x86_64-win32-seh-rev0, Built by MinGW-W64 projec
t' --with-bugurl=http://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -I/
c/mingw520/x86_64-520-win32-seh-rt_v4-rev0/mingw64/opt/include -I/c/mingw520/pre
requisites/x86_64-zlib-static/include -I/c/mingw520/prerequisites/x86_64-w64-min
gw32-static/include' CXXFLAGS='-O2 -pipe -I/c/mingw520/x86_64-520-win32-seh-rt_v
4-rev0/mingw64/opt/include -I/c/mingw520/prerequisites/x86_64-zlib-static/includ
e -I/c/mingw520/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLA
GS='-pipe -L/c/mingw520/x86_64-520-win32-seh-rt_v4-rev0/mingw64/opt/lib -L/c/min
gw520/prerequisites/x86_64-zlib-static/lib -L/c/mingw520/prerequisites/x86_64-w6
4-mingw32-static/lib '
Thread model: win32
gcc version 5.2.0 (x86_64-win32-seh-rev0, Built by MinGW-W64 project)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=core2' '-march=nocona'
 c:/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.2.0/cc1plus.exe -q
uiet -v -iprefix c:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/ -
U_REENTRANT firsteigen.cpp -quiet -dumpbase firsteigen.cpp -mtune=core2 -march=n
ocona -auxbase firsteigen -version -o C:\temp\ccRjLnLZ.s
GNU C++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) version 5.2.0 (x86_6
4-w64-mingw32)
        compiled by GNU C version 5.2.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "c:/mingw-w64/mingw64/lib/gcc/../../lib/gcc/x86_64-
w64-mingw32/5.2.0/include"
ignoring nonexistent directory "C:/mingw520/x86_64-520-win32-seh-rt_v4-rev0/ming
w64C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../include"
ignoring duplicate directory "c:/mingw-w64/mingw64/lib/gcc/../../lib/gcc/x86_64-
w64-mingw32/5.2.0/include-fixed"
ignoring duplicate directory "c:/mingw-w64/mingw64/lib/gcc/../../lib/gcc/x86_64-
w64-mingw32/5.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/mingw520/x86_64-520-win32-seh-rt_v4-rev0/ming
w64/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 c:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/include
 c:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/include-fixed
 c:/mingw-w64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.2.0/../../../../x86_64
-w64-mingw32/include
 c:/mingw-w64/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++
 c:/mingw-w64/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/x86_64-w64-mi
ngw32
 c:/mingw-w64/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/backward
End of search list.
GNU C++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) version 5.2.0 (x86_6
4-w64-mingw32)
        compiled by GNU C version 5.2.0, GMP version 6.0.0, MPFR version 3.1.3,
MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fb424bf2d94fed3543366c13b326a53d
firsteigen.cpp:2:23: fatal error: Eigen/Dense: No such file or directory
compilation terminated.

【问题讨论】:

【参考方案1】:

假设完整路径是c:/some/random/path/Eigen/Dense。您需要传递给 gcc 的包含路径是 c:/some/random/path/。请注意,在Dense 文件的同一级别,您应该有src 文件夹。

【讨论】:

以上是关于mingw windows找不到Eigen头文件的主要内容,如果未能解决你的问题,请参考以下文章

使用 Eclipse + CDT + MinGW32 开发 C++ Socket 程序找不到库文件和头文件

C++ MinGW 如何从 Windows 编译 Linx

Mingw中头文件"Windows.h"的问题

Windows程序移植到linux下 出现很多头文件里面定义的变量在linux中找不到想对应的头文件?求救~~~

用VisualC++6.0进行windows编程时提示找不到helper.h头文件,咋办?

QT用VS还是MINGW编译好,有啥区别