Visual Studio 2019 x64 app using mongocxx driver - c++

I'm trying to get a windows x64 C++ project working with the latest mongocxx driver using Visual Studio 2019. I installed the driver libraries using vcpkg:
vcpkg install mongo-cxx-driver[boost]
In VS 2019 I created a new console app and inserted the example code from the mongo driver page into main(). I built the app and ran it; everything works great. Then I noticed that it built as a win 32 app and switched it over to x64. Now the project won't build b/c it can't find the header files. Specifically (1rst error only...the others are similar)
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'bsoncxx/json.hpp': No such file or directory
What do I need to do to make it work on the x64 platform?

As I suspected, it was something I just didn't know to do. From Neumann-A on the vcpkg github site:
vcpkg install mongo-cxx-driver[boost]:x64-windows
or
vcpkg install mongo-cxx-driver[boost] --triplet x64-windows
or
set VCPKG_DEFAULT_TRIPLET=x64-windows
vcpkg install mongo-cxx-driver[boost]

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.

Visual Studio 2022 intellisense cannot find Openssl (ARM64 - Makefile project - SSH - Ubuntu)

(Only to be clear, this question is regarding Intellisense only)
Here is my developing scenario:
Visual Studio 2022 (Enterprise edition, 64 bits)
C++ project (Run by SSH to a Raspberry Pi 4 - ARM64 using Ubuntu 20.04 server)
Project is a Makefile project (not CMake).
The code compiles and runs in the Raspberry Pi (via SSH), but the problem is with Visual Studio Intellisense that cannot find the OpenSSL files.
I ran the tutorial here (https://kontext.tech/article/594/microsoft-vcpkg-c-library-manager) and installed vcpkg
vcpkg install openssl:arm64-windows
and ran the instruction to integrate to Visual Studio
vcpkg integrate install
and everything seems to be installed correctly,
PS C:\vcpkg> .\vcpkg.exe integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.
but as this is a Makefile project (and not CMake), it still seems to have the problem with Intellisense.
Could you please help me to determine how to make Visual Studio to finally find the OpenSSL files?
Thank you.
I made progress in solving the problem in an unexpected way. As the project built successfully in the remote machine, I ignored the Intellisense problems for a while. But one day I connected to another machine and there were no problems! Intellisense found all the files.
The machine with problems had Ubuntu 20.04 and the other one Raspbian OS. The difference was that I installed OpenSSL using apt in Ubuntu,
sudo apt -y install libssl-dev
but I compiled the OpenSSL source code in the Raspbian OS. (https://www.linuxtuto.net/blog/how-to-install-OpenSSL-3-on-Ubuntu-20-04) and (https://nextgentips.com/2022/03/23/how-to-install-openssl-3-on-ubuntu-20-04/)
So I knew the problem was due to the headers.
I compiled OpenSSL from source in Ubuntu, and it didn't work. But I had a third machine with Ubuntu 22.04 and did the same, and it worked. So I knew the exact problem: Visual Studio didn't bring the headers after an initial SSH connection was made.
Solution:
[IMPORTANT] Download OpenSSL source code using the tutorials I linked above, and compile it in your Linux machine (mine was an upgrade from 1.1.1f to 3.0.5).
Go to C:\Users[Your user]\AppData\Local\Microsoft\Linux
Depending on your Visual Studio version (mine is 2022), you will have a folder structure. Search around and you will find an XML file with your connection information (in my case, it was in User Data\3.0\store.xml)
Open the XML. You will have a list of all the SSH connections that version of Visual Studio has made to remote machines.
Check in the HeaderCache\1.0 folder. You will find folders with random numbers, and they match the connections from the XML. Identify the problematic connection.
Inside Visual Studio, delete that SSH connection. (It should also disappear from the XML, but it DOES NOT automatically delete the folder, so this is why the problem happened in the first place).
Delete the associated folder inside the HeaderCache\1.0 you found in step 4.
Recreate the SSH connection inside Visual Studio. It should appear in the XML and a new folder must be created inside HeaderCache\1.0.
Check inside the new folder. Go to the subfolder usr\include. There should be an OpenSSL folder.
Change the configuration of your solution in Visual Studio to use the new SSH connection.
Problem solved!
Edit: Sometimes you must delete your Visual Studio Configuration (inside the Configuration manager). After you delete the problematic configuration, in some cases Visual Studio still shows it inside the project properties. If that is your case, you must:
Open the Package Manager Console (Tools -> Nuget Package Manager -> Package Manager Console)
Run the command:
Get-Project -All | Foreach { $_.ConfigurationMAnager.DeleteConfigurationRow("Name of your configuration with quotes") }
And that's it!

how to install vcpkg for vs code?

I tried to install vcpkg for VS code and in a PowerShell Window. I had this error:
Could not find MSBuild version with C ++ support. VS2015, VS2017 or VS2019 (with C ++) must be installed.
So I installed Visual studio and I have the same error. What should I do?
Run vcpkg integrate install to customize Visual Studio Code on Linux or macOS. This command sets the location of the vcpkg enum and enables IntelliSense for the source files.
Look at this web page: https://learn.microsoft.com/ru-ru/cpp/build/vcpkg?view=msvc-160#integrate-with-visual-studio-code-linuxmacos

Visual Studio 2017 with CUDA cannot open include file 'cuda.h'

I am working on the Nvidia SDK with Visual Studio and I have been running into the error of this whenever I am trying to compile the sample from Nvidia:
Severity Code Description Project File Line Suppression State
Error C1083 Cannot open include file: 'cuda.h': No such file or
directory AppDecPerf
c:\users\administrator\desktop\video_codec_sdk_8.1.24\samples\appdecode\appdecperf\appdecperf.cpp 12
I do have CUDA installed on my computer and it looks like I have to link it with the IDE somehow but I just cannot find 'cuda.h' file anywhere.
Any help is appreciated. Thanks!
Install cuda library( static or dynamic) for Windows in vc++ 2017 using vcpkg.exe. Use .\vcpkg integrate install to automatically link the project to your solution.
Use .\vcpkg install cuda:x64-windows-static to install.
Right click your project, choose Build Dependencies then Build Customizations. From here you can choose the version of the CUDA Toolkit that you'd like to work with (amongst other things it will add the $(CudaToolkitDir) variable, and a new CUDA C/C++ tab to the project properties). The samples from NVIDIA should already be configured this way, but I've noticed that they can break when upgrading the SDK.
Further details are available here:
https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html#build-customizations-for-existing-projects

How to compile a C program with Visual Studio on Windows?

I am trying to compile a library for 2D localization called libdots which can be found on this website with Visual Studio 2015 on Windows for x86 or x64.
The following is stated in the readme file of the lib:
It is written in pure c and has no external library dependencies other
than 'libc'.
What I have done so far:
Installed OpenCV 3.0.0 to C:/opencv
Installed CMake for Windows
Installed MinGW
Set the following System Environment Variable:
OPENCV_DIR C:\opencv\build\x86\vc12
Added the following to the Path variable in Windows settings:
%OPENCV_DIR%;
C:\opencv\build\x86\vc12\lib;
C:\opencv\build\include;
C:\opencv\build\include\opencv;
C:\opencv\build\include\opencv2
Then I configured and generated the Makefile with cmake-gui and selected Visual Studio 14 2015 generator with "Use default native compilers":
This produced a Visual Studio Solution file (*.sln). Opening this file shows me the complete C project in the IDE. But when trying to build the project, I get the following errors:
Does somebody have a hint how to proceed and/or solve these issues?