致命错误:特征/密集:没有这样的文件或目录 [英] fatal error: Eigen/Dense: No such file or directory

查看:108
本文介绍了致命错误:特征/密集:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 libeigen3-dev 以便使用Eigen 3编译程序。当我包含文件时,例如 Eigen / Dense 尝试运行 g ++ 时出现此错误:

I have installed libeigen3-dev in order to compile programs using Eigen 3. when I include a file, such as Eigen/Dense I get this error when I try to run g++:

user@office-debian:~/Documents/prog$ g++ src/main.cpp -MMD -std=c++11
In file included from src/main.cpp:9:0:
src/tdefs.h:16:23: fatal error: Eigen/Dense: No such file or directory
compilation terminated.

运行以下行即可:


g ++ -I / usr / include / eigen3 / src / main.cpp -MMD -std = c ++ 11

g++ -I /usr/include/eigen3/ src/main.cpp -MMD -std=c++11

应该不会因为我通过aptitude安装Eigen软件包而由GCC自动找到包含目录?为什么在我安装库而不是安装Eigen时会自动找到boost和OpenGL? (请注意,eigen是仅标头的库,但这没关系吧?)

shouldn't that include directory be automatically found by GCC because I installed the Eigen package through aptitude? Why are boost and OpenGL found automatically when I install the libraries but not Eigen? (Note that eigen is a header-only library, but that shouldn't matter right?)

运行 g ++ src / main.cpp -MMD -std = c ++ 11 --verbose 产生以下输出:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5) 
COLLECT_GCC_OPTIONS='-MMD' '-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -MMD main.d -D_GNU_SOURCE src/main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -std=c++11 -version -o /tmp/ccoYRPKY.s
GNU C++ (Debian 4.7.2-5) version 4.7.2 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.7
 /usr/include/c++/4.7/x86_64-linux-gnu
 /usr/include/c++/4.7/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++ (Debian 4.7.2-5) version 4.7.2 (x86_64-linux-gnu)
    compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 66d178dd81da8c975e003e06d9f5e782
In file included from src/main.cpp:9:0:
src/tdefs.h:16:23: fatal error: Eigen/Dense: No such file or directory
compilation terminated.


推荐答案

使用运行编译器--verbose 开关:

g++ --verbose ...

如果您的包含相对于此输出中显示的路径之一,则不必使用 -我。这取决于gcc的配置方式,以及其他东西的安装位置。

If your includes are relative to one of the paths shown in this output, you don't have to use -I. It depends how gcc has been configured, and it depends where that other stuff is installed.

请注意,是通常不在-I路径中。

Note that . is typically not in the -I paths.

稍后

在注释中,很明显 / usr / include / eigen3 / Eigen / Dense 应该由 #include< Eigen / Dense> ,但不是通过 #include< eigen3 / Eigen / Dense> 。因此,必须添加命令行选项 -I / usr / include / eigen3

After exchanging a couple of comments it is clear that /usr/include/eigen3/Eigen/Dense should be include-able by #include <Eigen/Dense>, but not by #include <eigen3/Eigen/Dense>. Therefore, the addition of the command line option -I /usr/include/eigen3 is mandatory.

是否有些安装选择将头文件安装到目录中,该文件是在编译为gcc的目录中的一个目录中的,取决于默认值,分发者的决定或安装过程中的决定。我想说的是,常用头文件(Boost)放在/ usr / local / include中的位置很好,而某些精巧的东西最好放在自己的目录中。

Whether some installation selects to install header files into a directory that in one of the ones compiled into gcc, depends on the default, a decision made by the distributor, or a decision made during installation. I'd say that "frequently used" header files (Boost) are well placed into /usr/local/include while some "elitist" stuff would be better off in a directory of its own.

这篇关于致命错误:特征/密集:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆