Search code examples
c++visual-studiomakefileopensslintellisense

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.

Visual Studio cannot find OpenSSL

vcpkg installation result


Solution

  • 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:

    1. [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).
    2. Go to C:\Users[Your user]\AppData\Local\Microsoft\Linux
    3. 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)
    4. Open the XML. You will have a list of all the SSH connections that version of Visual Studio has made to remote machines.
    5. 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.
    6. 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).
    7. Delete the associated folder inside the HeaderCache\1.0 you found in step 4.
    8. Recreate the SSH connection inside Visual Studio. It should appear in the XML and a new folder must be created inside HeaderCache\1.0.
    9. Check inside the new folder. Go to the subfolder usr\include. There should be an OpenSSL folder.
    10. 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:

    1. Open the Package Manager Console (Tools -> Nuget Package Manager -> Package Manager Console)
    2. Run the command:
    Get-Project -All | Foreach { $_.ConfigurationMAnager.DeleteConfigurationRow("Name of your configuration with quotes") }
    

    And that's it!