0

I'm a neophyte. I know I'm doing something bonheaded. I've search this and other fora for the last day and I'm stuck. I'm trying to use nlohmann's json library. I'm getting over 200 error messages, most of which seem to be rooted in the fact that the compiler can't see the header references in the main json.hpp file, but can see the json.hpp file.

I've copied the nlohmann library contents into the source folder and this is the code at the moment:

#include <iostream>
#include "nlohmann\json.hpp"
using json = nlohmann::json;

int main()
{
    std::cout << "Hello World!\n";
}

I'm trying to minimize the number of variables I have to chase.

VS is finding the json.hpp file (no squiggly underline once I finally spelled it right, and a bunch of stuff in solution explorer under json.hpp and nlohmann) It also seems to be seeing the subdirectories of nlohmann

the 'json' after nlohmann:: has a squiggly underline; the popup says: namespace 'nlohmann' has no member 'json'

the first 20 or so 211 (!) error messages are code E1696 'cannot open source file' pointing to apparent references from json.hpp an example is: "E1696 cannot open source file "nlohmann/adl_serializer.hpp" json5 C:\Users\Rich\source\repos\json5\json5\nlohmann\json.hpp"

I've added the 'nlohmann' directory to the include directories that the compiler looks for (Project|properties|C/C++|Additional Include Directories) - no change in error message count. Do I need to manually add all of the subdirectories?

ozindfw
  • 21
  • 5
  • 1
    After adding `nlohmann` directory to include directories, what happens when you change the include statement to `#include "json.hpp"` ? – Bob Dalgleish Jan 06 '20 at 22:11
  • adding nlohmann directory had no effect on the display, or on the list of errors. I ended up using the Boost ptree libraries for this. – ozindfw Feb 25 '20 at 15:11
  • And sorry for taking so long on this, I lost track of the thread and just now found it again. – ozindfw Feb 25 '20 at 15:17

1 Answers1

2

I Think you maybe using an older version of c++ (older than c++11). Try adding this flag to the command -std=c++11.