How to use jsoncpp with Visual Studio 2022 - c++

I need my project to be able to use json format.
I was suggested this github : https://github.com/open-source-parsers/jsoncpp
I have been trying to integrate it to my project for multiple hours and still cant find the issue.
I still get these errors on my include :
#include <jsoncpp/json/json.h>
E1696 cannot open source file "jsoncpp/json/json.h"
C1083 Cannot open include file: 'jsoncpp/json/json.h'
I tried to go to C/C++ General->Additional Include Directories>
to add the "jsoncpp-master\include" directory
also tried "jsoncpp-master\include\json" directory
also tried to add the .h and .cpp found in the repository directly.
I have also tried a multitude of other things but I'm not sure it would be relevant to list them all here.
I was not able to find instructions to use it with Visual Studio 2022 on their github either.

Safest and most convenient way to use third party libraries is to use package manager like vcpkg
https://vcpkg.io/en/index.html
https://github.com/microsoft/vcpkg
Choose what build you want x86 or x64 and set default triplet in your environment variables
VCPKG_DEFAULT_TRIPLET
x64-windows - DLL Build 64-bit windows
x86-windows - DLL Build 32-bit windows
x64-windows-static - Static Build 64-bit windows
x86-windows-static - Static Build 32-bit windows
If you have added jsoncpp-master\include to C/C++ General->Additional Include Directories then you should use #include <json/json.h> instead of #include <jsoncpp/json/json.h>
Explanation : The compiler is looking inside the include directory. If you observer the file structure you can see json folder is located in the include directory and not jsoncpp.

Related

How to see definitions in Visual Studio for files installed using vcpkg?

I'm using vcpkg library manager and with it I've installed gtk.
In VS2019 I have included #include "gtk/gtk.h" and when I Ctrl+Click on that line I end-up in that header file. Then I go to #include <gtk/gtkmain.h> and in there we see a bunch of interesting functions, for example gtk_init_abi_check. But this is only a declaration and I would like to see implementations (definitions) of these functions. RightMouseClick -> Go to declaration on function's name doesn't do anything.
Can I even use vcpkg for getting the libraries but also the code that I can read?
The simple way is to add gtk projects to your main Visual studio solution :
Download and extract vcpkg
Add all vcpkg projects
Search vcxproj in toolsrc present in the extracted folder (step 1)
Do same thing for vcpkg, vcpkglib and vcpkgtest if you want test project
Thea goal is to integrate gtk projects to your solution:
Now, you can use go to implementation
Remarque : If your main VS solution has a different version from the downloaded librarie, use Cmake to generate a new vcpkg, vcpkglib and vcpkgtest projects and do the same thing

OpenCV w/ CUDA build fail on Visual Studio 2013 [duplicate]

I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from https://github.com/Itseez/opencv I generate (leaving the default configuration) using cmake and then load the resulting file ALL_BUILD.vcxproj into Visual Studio 2012. I then try to build it. Several of the modules do indeed build (e.g. core, flann, imgproc, ...) but I am trying to build highgui so that I can use the PDB file for debugging my code (which fails to open a video file). The build errors start with this and many similar errors:
error C2039: 'max' : is not a member of 'std' C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp 1094 1 IlmImf
One fix for errors like this (e.g. in this answer) is to add #include <algorithm> to the failing files. I tried that on a few files and it seems to work but I'm nervous about locally changing the source for a popular library. It must build on Windows (you can download the binaries, though not the PDB files, from the OpenCV sourceforge site) so I would like to understand how to build it on my machine without changing the source.
Am I missing something out in the configuration step? Is there some path setting etc. missing on my machine? Why am I getting these errors and how should I fix them?
========== EDIT ==========
Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking on Github it appears to be version 1.7.1 of OpenEXR that is used in OpenCV 2.4.6. The instructions in the OpenCV's Quick Start Installation on Windows state:
In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.
Same as above with OpenEXR.
so I downloaded the OpenEXR 1.7.1 source code release and extracted the resulting files putting the directory openexr-1.7.1 into C:\OpenCV2.4.6\dep.
Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.
I was stumbling on the same issue while compiling OpenEXR. Then I found the solution googling for openexr std::min.
There is an issue opened on OpenCV where it says that, when using VS2013 Preview, you must add the line #include <algorithm> in the file where you're using std::min and std::max.
I put that line into the files where these methods are called and voilĂ ! Compilation succeeded.
You probably need to #define NOMINMAX. Try putting it before any other includes.
If that helps, then put in the you project's preprocessor defines.
There's lots of info about this, just search for NOMINMAX. Here's one post about it.
#include <iostream>
#include <algorithm>
Just include above 2 lines to the cpp file and the compilation error will disappear.

Visual Studio not using additional include directories for KinectBridgeWithOpenCVBasics D2D C++ Sample, but does for other solutions.

I'm working on adding some openCV features to a couple projects that use the Kinect and openGL/freeGLUT. I have downloaded and installed OpenCV using the pre-built libraries and successfully run a simple sample. Now I want to work with the Kinect Bridge with OpenCV Basics sample from the Kinect for Windows Developer Toolkit to get a better idea of how to use OpenCV with the Kinect. I downloaded the sample into my projects folder, opened the solution in visual studio and built it. I got the following errors:
Error 1 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVHelper.h 17
and
Error 2 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVFrameHelper.h 13
Initially I thought these errors were due to forgetting to specify the additional include directories. I added the same property sheet that my other OpenCV projects use to this one, but the errors remained. I tired copying the header files into the project folder: same thing. It seems like the only thing that works is specifying the full absolute file paths in the #include statements. I want to avoid doing this because visual studio wants me to change every #include in every file used in the project, including the openCV header files. I also tried shortening the name of my project folder in case the file path was too long (though I'm pretty sure that's more of an issue for the header file paths), but again no change.
The include directories and #includes that I'm trying to use are the same as in my other projects. I'm using Visual Studio 2010 on Windows 7 x64 based system.
Why would the additional include directory work for other projects, but not this one?
Usually when I see something like this it turns out to be a bad character in one of the prior include paths or other options that's messing everything up after it. I would take a look at your the command line page in the project configuration and see if you can spot anything amiss.

Add OpenSSL static libraries to a vc++ project

I have some problems adding the OpenSSL libraries to my visual vc++ project.
I tried everything I could find but I am still unable to include any .h files in my code.
I have a directory where I put my .lib (libeay32.lib and ssleay32.lib) libraries in a sub directory of my project called "Lib". I also have a environment variable pointing to my OpenSSL installation folder called "OPENSSL". Here's some screenshots of my project's config:
Still with all that if I write #include "rsa.h for example, Visual Studio tells me it doesn't exist. What did I miss?
Have you tried including like this:
#include <openssl/rsa.h>
or
#include <rsa.h>
Which proper way of including is the first one, unless you've added inside of openssl folder in your include path

unable to compile examples in ODEINT package

I am trying to solve a coupled set of ODE's in C++, and I have decided that I want to try out odeint (available here) as I have read many good things about it. However I am having compiling the examples that are included in the package. Here is the situation:
So far I have only downloaded the package and extracted it. I am running Visual C++ 6 on Windows XP and I am compiling the example "simple1d". I get the error message: "Cannot open include file: 'boost/config.hpp': No such file or directory".
It is not clear to me what I am missing. Do I need the full boost library to make this work? I was under the impression that ODEINT is a "standalone" package.
Your error says that compiler can not find the boost libraries. You should download them from boost.org and also add them to your header path.
Where did you download and extract the package to? The package homepage says that it's a header-only package, so you only need to let Visual find the header files. I haven't used Visual in a while, but a quick google of something like "Visual 6 add header path" should be a good place to start. Take a look at Where does Visual Studio look for C++ header files?.
Quoting from this page:
Within Visual Studio, go to the Project Settings dialog. We want to change the settings for both Debug and Release versions, so under the Settings For field, select "All Configurations". Under the C/C++ Tab, select Preprocessor options.
The package tarball has a directory called boost: you want to add the path of that directory into the Additional include directories box and then #include <boost/numeric/odeint/config.hpp> in your code.
Update
It appears, then, that you already have the odeint headers installed properly: the file boost/numeric/odeint/config.hpp has a line #include <boost/config.hpp>, which is what visual must be complaining about; so I guess the package is not standalone. It must need other boost header files installed. I can't find anything in either the package homepage or the package tarball that mentions any dependencies, so I suppose you should try to install boost too. Download version 1.51.0 here, and this is the windows documentation.
You must download odeint from http://headmyshoulder.github.io/odeint-v2/downloads.html and Boost c++ libraries from http://www.boost.org/users/history/version_1_51_0.html.
If you use codeblocks right click your project, select build oprions, select Search Directories and add two references one for odeint and one for boost.