小编pra*_*ale的帖子

如何正确配置cmake文件来为nlohmann_json构建一个简单的hello world?

我正在使用以下 JSON 解析器: https: //github.com/nlohmann/json

以下是我构建的步骤:

 2074  git clone https://github.com/nlohmann/json.git
 2075  git branch
 2076  ls
 2077  cd json/
 2078  git branch
 2079  git pull
 2080  ls
 2081  vi CODE_OF_CONDUCT.md 
 2082  mkdir build
 2083  cd build/
 2084  ls
 2085  cmake ..
 2086  cmake --build .
 2087  ctest --output-on-failure
Run Code Online (Sandbox Code Playgroud)

单元测试通过。正如文档所述,我没有看到正在构建的库。

我正在尝试为解析器构建一个简单的 hello world 程序。这是代码:

#include <nlohmann/json.hpp>
#include<string.h>
// for convenience
using json = nlohmann::json;

int
main(int argc, char *argv[])
{
    std::ifstream ifs("test.json");
    json jf = json::parse(ifs);
     return 0;
}

Run Code Online (Sandbox Code Playgroud)

和 CMake 文件: …

c++ cmake nlohmann-json

5
推荐指数
1
解决办法
7782
查看次数

标签 统计

c++ ×1

cmake ×1

nlohmann-json ×1