spdlog 意外包含参考点

spdlog unexpected include reference point

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

#include "spdlog/spdlog.h"

int main()
{
    return 0;
}

因为它是 "header only" 库,所以我只是将它复制到我的项目的根目录并希望一切正常。

|+ 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" 被添加到所有 headers 的所有包含中?
我应该怎么做才能使用 spdlog?编辑其包含?

由于您的头文件路径是 spdlog/.h,因此您应该提供 spdlog 文件夹所在的路径。喜欢

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