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

(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!

Related

Visual Studio 2019 x64 app using mongocxx driver

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]

Visual Studio: copy installation folder and setup it up to be auto-detected by Qt Creator

I wiped out an old Windows 10 and replaced it with a new Windows 10 by ISO image.
Before wiping out, I copied the folder of Microsoft Visual Studio 2017 Community Edition on old Windows to an external hard disk:
xcopy /E "C:\Program Files (x86)\Microsoft Visual Studio" D:\
Now after reinstalling Windows 10, I copied the VS 2017 folder from external the hard disk to the C:\Program Files (x86)\ folder of new operating system.
I did so to avoid having to download VS 2017 again on new OS.
The problem is other software, like Qt Creator, cannot auto-detect the VS C/C++ compilers. I guess that's because the VS 2017 isn't added to path.
The questions are:
What path should I add to system path in order to VS 2017 to be auto-detected by other software like Qt Creator?
Is there any script which I can run to automatically integrate the VS 2017 to the rest of the operating system.
To answer the questions in your issue:
Copying the content of C:\Program Files (x86)\Microsoft Visual Studio folder is not a recommended way to install VS.
(The complete installation will not only set the Environment variables but also set the related registry keys and values. A simple copy may break this process)
So we always suggest that users install the VS by vs-installer or offline installation package. (Same like what Zlatomir suggests.)
To your actual requirements:
It seems you're just trying to use VC++ compiler in QT Creator instead of developing QT projects in Visual Studio. So build tools for VS package is enough for you.
See this related issue, if we download Build Tools for VS package with corresponding C++ workload, then we can get the compiler the QT needs. There's no need to install the VS IDE for this situation.
And if we need C++ compiler from VS2017, download the Build Tools for VS2017, if we need C++ compiler from VS2015, download the Build Tools for VS2015 Update3. Link of old version about VS Tools see here.
Update:
From the the link older downloads we can see:
Choose the download button according to which version we need. We can find both VS2017 build tools package and VS2015's there.
Usually programs on Windows don't work after you just copy the installation folder.
So right now there is little you can do to fix it, even if you partially fix, you have no way to know if something else will be broken in the future.
So the recommended solution is to download the installer again and create an offline installer for the next time this happens, you can do that by running the online installer with the following parameters: vs_community.exe --layout c:\vslayout --lang en-US (replace vs_community.exe with the actual name of the online installer file, or rename it), for more options, that might require a smaller download (example if you only need native and don't need .net) check the documentation here for the full set of options you have.

Adding Casablanca Dependency VS2017

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.

Visual Studio 2013 Ultimate - Missing C++ Projects Templates

I installed fresh install of my Microsoft Visual Studio Ultimate 2013 and launched it. I then went to FILE -> New -> Project and wanted to create new C++ project. However, there is no option for creating such project now (I know it was there before, on my second laptop). I restarted installer and pressed repair, but nothing changed. I also tried to uninstall it and then install it back again. I also have MSVC2015 RC and I can create C++ Projects there. During an installation I was asked if I want to install certain features as well and I did install everything that was offered.
This is how my New Project looks like.
What is going on in there? Did I forget to install something?
I had the same issue with VS2012, some time ago. I've solved installing again. Not sure if VS2013 makes you configure if you want to install "C++ stuff" during the installation process.

How to compile code with visual studio using makefile

I have just downloaded a open source project which is said to be compiled using visual studio c++. It contains 3 makeFiles (makeFile, makeFile(1) and makeFile(2) )
I always open programs in VS using the .sln files and now I dont know what to do with this makeFile.
can anyone instruct me how to deal with it please.
regards
You may try NMake. See NMake Reference and Stackoverflow post.
NMake is included with Visual Studio. You may try with NMake shipped with the edition of Visual Studio you may want to use.
If you are only familiar with Visual Studio projects and solutions, dealing with makefiles can be a challenge. The following link will give you a good introduction to makefiles from a Visual studio perspective.
An introduction to Makefiles for Visual Studio developers
Translating Linux makefiles to Visual Studio solution will be a manual effort.
NMake looks promising. However, the following link takes a simple Makefile and explains some fundamental issues that one may encounter.
Makefiles in Windows
VS2017 and cross-platform dev with make linux binaries
If you're working on windows 10, you can make make work and compile linux binaries:
have lxss installed, and gdb server, ssh server installed:
sudo apt update &&
sudo apt install -y build-essential gdbserver openssh-server
make sure you can connect through ssh to your local machine:
sudo vi /etc/ssh/sshd_config &&
sudo service ssh start
make sure you have linux development with c++ packages installed (VS2017 install)
make sure you configured your connexion to lsxx through ssh in VS/tools/options/connection manager ("connection" in search).
make sure to have a linux project (new project/other languages/vc++/crossplatform/linux)
yet, add you make commands in project/properties.
I've just run into the same problem and for me the solution:
open "VS2012 Native Command Prompt" the name varies over different versions of MSVS. then simply type 'nmake makefile.vc'. nmake is the command, makefile.vc is your own makefile in your local folder. and it is done (if no further errors occur)