首页 > 解决方案 > 包含现有标题的致命错误

问题描述

当我尝试使用 Fastor-Library ( https://github.com/romeric/Fastor ) 并包含该库时,我收到错误消息,即 repo 中的文件夹不存在。这是代表我的错误,还是我应该向 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.

你能重现错误,还是我做错了什么?

标签: c++include

解决方案


你的编译器命令应该是:

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

你应该只包括"Fastor.h"而不是"Fastor/Fastor.h".


推荐阅读