5

I am having some trouble getting the JSONCPP Library into Visual Studio.

I have downloaded the library I am just unsure how to import it into my project and use it in my c++ code.

blakepeterman
  • 328
  • 2
  • 4
  • 15
  • What exactly is the problem? Is it a static library? DLL? Or do you have to compile it yourself? – Cameron Nov 05 '14 at 22:52
  • https://github.com/open-source-parsers/jsoncpp – blakepeterman Nov 05 '14 at 22:54
  • I basically do not know to take this library and use it in c++. – blakepeterman Nov 05 '14 at 22:55
  • 2
    The documentation is actually quite good -- I suggest following the instructions for [generating an amalgamated .h & .cpp](https://github.com/open-source-parsers/jsoncpp#generating-amalgamated-source-and-header). Then you can just drop them into your project (`Add->Existing Item` in VS). After that all you need to do is include the header wherever you want to use jsoncpp. – Cameron Nov 05 '14 at 23:06
  • I did that but I am getting a error: "cannot open include file: 'json/json.h' no such file or directory". – blakepeterman Nov 05 '14 at 23:16
  • Well, does that file exist on disk? Where did you put the `json.h` file relative to the file you're including it in? – Cameron Nov 05 '14 at 23:29
  • I did exactly what you mentioned. I added each of the files as existing items. The .h files json.h and json-forwards.h are in the header files jsoncpp.cpp is in the source files folder. – blakepeterman Nov 05 '14 at 23:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/64355/discussion-between-blakepeterman-and-cameron). – blakepeterman Nov 05 '14 at 23:39

1 Answers1

4

To fix the error "cannot open include file: 'json/json.h' no such file or directory", you need to add Include directory to your project as following:

-Right click on your project -> Properties. Under C/C++ ->General ->Additional Include Directories, add C:\your-directory-to-jsoncpp-master\include (e.g. C:\user1\jsoncpp-master\include).

Key
  • 139
  • 1
  • 9