包含现有标头时出现致命错误

时间:2019-02-13 12:39:17

标签: c++ include

当我尝试使用Fastor-Library(https://github.com/romeric/Fastor)并且包含该库时,出现错误,即回购内的文件夹不存在。这是我的错吗?还是应该与Fastor的作者讨论一个问题?

代码:

#include "Fastor/Fastor.h"

int main(){
    Fastor::Tensor<double,2> A;
    return 0;
}

文件夹结构:

total 8
drwxr-xr-x 15 name name 4096 Feb 13 13:19 Fastor
-rw-r--r--  1 name name   82 Feb 13 13:20 main.cpp

为什么会出现以下错误?

g++ -std=c++14 -O3 -mavx -DNDEBUG main.cpp -o main
In file included from Fastor/simd_vector/SIMDVector.h:4:0,
                 from Fastor/Fastor.h:6,
                 from main.cpp:1:
Fastor/simd_vector/simd_vector_base.h:4:10: fatal error: commons/commons.h: No such file or directory
 #include "commons/commons.h"
          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

您能够重现该错误,还是我做错了什么?

1 个答案:

答案 0 :(得分:0)

您的编译器命令应为:

g++ -std=c++14 -O3 -mavx -DNDEBUG main.cpp -o main -I Fastor

您应该只包含"Fastor.h"而不是"Fastor/Fastor.h"