I am trying to include the rapidjson
library in my VS community 2017 project.
On creating a new project, I tried including/adding the directory rapidjson-master\include\rapidjson
at the following places :
Properties -> Configuration Properties -> C/C++ -> General -> Additional Include Directories.
Properties -> Configuration Properties -> VC++ Directories -> Include Directories.
Either way, when I try to include a rapidjson
related file, VS tells me that it cannot find the source file.
So, when i give this :
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
I get the following errors :
Error (active) E1696 cannot open source file "rapidjson/document.h"
Error (active) E1696 cannot open source file "rapidjson/writer.h"
Error (active) E1696 cannot open source file "rapidjson/stringbuffer.h"
VS Info :
Microsoft Visual Studio Community 2017
Version 15.6.3
Let me know if you know the right way to use rapidjson
in Visual Studio.
EDIT :
The rapidjson documentation advises us to "just copy the include/rapidjson
folder to system or project's include path".
After spending some time trying to figure out why it wasn't including the external libraries, I finally found my solution.
When I was adding the path to my additional include directories
, I was doing it under the following configuration :
Configuration : Debug
Platform : x64.
However, in my VS2017, every time I create a new project, the default configuration that is set for compilation/run is as follows :
Configuration : Debug
Platform : x86
The main reason behind my problem was the mismatch of platforms between configuring the project and compiling the project. So, I guess it's always better to check if the platform and configuration is the same in such cases.
Additional Info : ( regarding the comments and the other answer to this question )
It doesn't matter if the directory included is rapidjson-master\include\rapidjson
or rapidjson-master\include\
. In the former we include the files as #include "document.h"
and in the latter it would be #include "rapidjson/document.h"
.