spdlog意外包含参考点

时间:2018-10-06 12:58:55

标签: c++ spdlog

我正在尝试在hello世界中使用spdlog库。

#include "spdlog/spdlog.h"

int main()
{
    return 0;
}

由于它是“仅标头”库,因此我将其复制到了项目的根目录,并希望所有内容都能正常工作。

|+ hello.cpp                         
|+ spdlog |         
          |+ spdlog.h
          |+common.h
     .....     

但是当我构建gcc hello.cpp

我知道了:
spdlog/spdlog.h:10:10: fatal error: spdlog/common.h: No such file or directory #include "spdlog/common.h"
问题在于,在spdlog库中的所有位置都引用spdlog文件夹下的文件。在上面的示例错误中,spdlog.h包含同一个文件夹中的common.h。但是它是这样包含的:
#include "spdlog/common.h" 为什么“ spdlog”在所有头文件的所有包含中都放在前面?
我应该怎么做才能使用spdlog?编辑其包含?

1 个答案:

答案 0 :(得分:1)

由于头文件的路径为spdlog / .h,因此应提供spdlog文件夹所在的路径。像

gcc -c -I/<Path of spdlog parent folder> hello.cpp