Adding Casablanca Dependency VS2017 - c++

I recently upgraded to VS2017 and I'm looking to start doing more C++ work. I've not used VS or C++ in a good while (and even at that I was a C++ novice).
I'm trying to install Casablanca, aka CPPRestSdk (https://github.com/Microsoft/cpprestsdk) but I can't seem to manage it.
I've tried installing it through NuGet but I'm not sure exactly what I've to link to my project, and I've tried vcpkg - to which I've downloaded via the instructions but I have no clue what to do there.
All the materials I find for this apply to earlier VS editions and don't appear to work when I try them. Has anyone had such luck with getting this to work? If not, is there an alternative that I can use that has clear installation instructions?
Thanks

I recently moved a C++ REST SDK based project from the older NuGet package to the recent VCPKG based 2.10.1 release. Apart from Visual Studio 2017 with the C++ for Desktop workload make sure you have Git for Windows installed. Clone the VCPKG repo from GitHub with
git clone https://github.com/Microsoft/vcpkg
I'd recommend using a directory not having any spaces in its path, otherwise some builds might fail. Change into the VCPKG directory and run the bootstrap script:
.\bootstrap-vcpkg.cmd
This will compile the package manager itself. Afterwards you can install the C++ REST SDK with
.\vcpkg install cpprestsdk cpprestsdk:x64-windows
This will download all required libraries and takes quite a while. For usage in Visual Studio you have to enable the system wide integration with
.\vcpkg integrate install
This requires elevated privileges the first time but afterwards the C++ REST SDK is available in any Visual Studio C++ project. Follow the instructions for getting started. As soon as you include a C++ REST SDK header into your project the linking is taking care of automatically by Visual Studio.
For consumption in a CMake project you have to pass the VCPKG toolchain file to the CMake command, e.g.
cmake -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
Referencing the C++ REST SDK from CMake is described in the project repo's README.

Related

Installing OR-Tools to Visual Studio 2022

I am trying to write a code using Google's OR-Tools on Microsoft Visual Studio 2022.
I followed the following steps:
Download OR-Tools from Binary on Windows on their website.
Extracted the .zip file in D:\CodeField
Wrote the complete TSP programs of their website on VS.
In Visual Studio, went to Project > Properties > C/C++ > Additional Include Directories
Added "D:\CodeField\or-tools_x64_VisualStudio2022_cpp_v9.5.2237\include"
Clicked Apply then OK then compiled my code.
I am getting a bunch of linking errors "1>ortools.lib(scip_callback.obj) : error LNK2001: unresolved external symbol SCIPconshdlrGetData".
what should I do?
Try adding the lib folder in linker settings and link ortools_full.lib. If there are other errors try changing the runtime library to /MD. Make sure you use C++17.
Visual Studio
To build and run OR-Tools on Windows, you must have Visual Studio 2019 or later installed on your computer with the C++ toolset for Visual Studio.
You can find more details here.
To build OR-Tools programs from the command line you must use a x64 Native Tools Command Prompt (not the Developer Command Prompt).
You can find more details here.
Git
Git, which can be downloaded from https://git-scm.com/.
CMake
CMake (>= 3.18), which can be downloaded from https://www.cmake.org/download. When installing CMake, select the option for a command-line accessible cmake.
.NET Core 3.1 SDK
You must install the package .NET Core 3.1 SDK version 3.1.100 or higher from the following location: sdk-3.1.425-windows-x64-installer
.Net 6.0 SDK
You must install the package .NET 6.0 SDK from the following location: sdk-6.0.403-windows-x64-installer
Download the source code
There are two distinct branches of the OR-Tools source code on GitHub: stable and main.
The stable branch has been thoroughly tested and should work flawlessly on all supported platforms.
The main branch is where the latest updates and improvements have been applied; it's more current, but less stable.

Building and running unit tests with Visual Studio build tools

I am adding unit tests to an existing C++ Visual Studio projects, using the Google Test adapter.
It's all running fine on my computer with Visual Studio 2019, but when I try to run them on the build server I get the following error
error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.1.8.1.3\build\native\Microsoft.googletest.v140.windesktop.msvcstl.static.rt-dyn.targets.
However, we're not using NuGet for package management. I tried installing it but complained about missing folders. This is not a .NET project, so I think that's a red herring.
I was able to install the Google Test adapter on my computer using the Visual Studio Installer, but it does not show up as a part of the VS Build Tools on the build server.
Running msbuild -t:restore does not help, it just reports "nothing to do."
I don't understand why the Google Test adapter isn't available for VS Build Tools, since it seems to be required in order to build the unit tests. Does anyone know why it doesn't work? What's the best practice for handling this?
Thanks!
The problem is that your c++ project has missed the content of googletest nuget package. So the solution is to restore the whole nuget package in your c++ project.
Update 1
First of all, take a brand new backed up project and restore it to when the problem started.
Besides, msbuild -t:restore command applies to projects with PackageReference nuget management format.
Since your c++ project used packages.config nuget management format, msbuild -t:restore will not work. See this official document.Instead, you should use nuget restore command.
This command works for your current project and running this command will restore the nuget packages and then you will never face the issue.
Before using it, you should download nuget.exe CLI and config its path into System Environment Variable PATH so that CMD can invoke nuget.
The steps about configing nuget.exe, you can refer to this link.
Steps
1) delete packages folder under the solution folder
2)Then, open build tool, run:
nuget restore xxx\xxx\xxx.sln(the full path of solution file containing the c++ project and the unit test project)
Then, you can build the project with the command. And I hope the error will disappear.

what is the general method to add opencv in visual studio for all programs?

I am trying to setting up opencv for my project in visual studio and for this I have seen so many blogs and forums but still I didn't find any way to add openCv in generalized way so every time I make new project, it should be added automatically. Is there any way to add openCv in visual studio so every time when I will make new project it should be added automatically, please share your answers. I want to save my time
Vcpkg is a package manager which helps you to manage C and C++ libraries on Windows, Linux and MacOS, available on GitHub.
Use vcpkg in the PowerShell command prompt .\vcpkg install opencv to install opencv and issue command .\vcpkg integrate install to integrate installed packages into your Visual Studio projects.

NServiceBus.Host.exe is missing while installing NServiceBus.Host on aspnetcore 2 in visual studio 2017

I am trying to run NServiceBus with AspNetCore2 on visual studio 2017. While I install NServiceBus(Version 7.0.0-beta0001) and NServiceBus.Host(Version 8.0.0-beta0001) through nuget, it says package installed successfully.
However, when i try to check installed dll's and exe files of NServiceBus within bin/debug folder, it's not there.
Quick observations i made are, NServiceBus (version 7.0...) is installed correctly whereas NServiceBus.Host (version 8.0....) is showing a warning message under nuget folder in visual studio:
Package 'NServiceBus.Host 8.0.0-beta0001' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Please help me to resolve this issue or point me to correct question if it's already been answered (which i could not find in SO)
NServiceBus.Host is being phased out for the reasons specified here. Long story short, in .NET Core it does not add much of a value and has more cons.
You can however, still run the NServiceBus process in a console app. Have a look at the self-hosting sample here.

I can't run openCV2.3.1 with VS2010 because opencv_core231d.dll was not found

I installed openCV2.3.1 with VS2010. In VC++ Directories I set Library Directories to C:\opencv\build\x86\vc10\lib. My code has no error but when I try to build it VC++2010 displays this error
This application has failed strat because opencv_core231d.dll was not
found. Reinstall the application may fix this problem.
How do I setup openCV2.3.1 with VC++2010 to find the .dll?
Have you seen Microsoft Visual Studio tutorial from the latest OpenCV documentation?
You need to build the openCV2.3.1 yourself. We use cmake build tool in our project. And you should copy the opencv_core231d.dll to your exe directory so that your executable file can find the dll.
Here is the Complete Installation guide for OpenCV.
Download and install the 2.3.1 superpack for Windows and configure Visual Studio according to this post. Even though the instructions are for the 2.3 version, the procedure remains the same and you just need to take care to use the appropriate paths and file names of v2.3.1 when following the steps.
Alternatively you could try to follow Andrey's recommendation, but I haven't test it yet.