小编Hop*_*ode的帖子

尽管 json.hpp 与 main.cpp 位于同一文件夹中,但出现“json.hpp:没有这样的文件或目录”错误

我正在尝试集成nlohmann中的 json c++ 库,同时只需将 'single_include' 文件复制到与我的 main.cpp 文件相同的目录。根据集成说明

json.hpp 是 single_include/nlohmann 中的单个必需文件或在此处发布。你需要添加

#include <nlohmann/json.hpp>

// for convenience
using json = nlohmann::json;
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,编译器认为那里不存在这样的文件,而且我不知道我可以采取什么不同的措施来使这项工作正常进行。

我收到的完整错误:

main.cpp:2:10: fatal error: json.hpp: No such file or directory
 #include <json.hpp>
          ^~~~~~~~~~
compilation terminated.
Run Code Online (Sandbox Code Playgroud)

(我猜测,由于 json.hpp 文件就在 main.cpp 文件旁边,因此我不应该编写它,#include <nlohmann/json.hpp>尽管它是按照集成说明中的方式编写的,对吧?)

*这是我在 VS Code 中的项目目前的样子

c++ json

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

json ×1