PROWAREtech
MS VC++ 2022 on Linux
This focuses mainly on the development of Linux server apps. This article is based on Microsoft's docs.
See also: Build and run Blazor WASM projects on Linux
Visual Studio 2022
Open Visual Studio 2022 and choose to create a new project. Search for Linux projects and choose Console Application with the "hello" example.
-
Choose your project's architecture.
-
Update the repository on the Linux machine.
On Ubuntu, issue this command:
sudo apt-get update
On Fedora/CentOS, be logged in as user root and issue this command:
yum update
-
Install prerequisite packages on the Linux machine: openssh server, g++, gdb and gdb server
On Ubuntu, issue this command:
sudo apt-get install openssh-server g++ gdb gdbserver make ninja-build rsync zip
On Fedora/CentOS, be logged in as user root and issue this command:
yum install openssh-server g++ gdb gdb-gdbserver ninja-build make rsync zip
-
Hit the F5 key and the project will try to connect to a remote system. Enter the host machine's IP address, user name and password.
-
To add another connection/remote machine, go to Tools > Options and search for Connection Manager.
-
To change the connection/remote machine the project is using, go to the project's properties and change Remote Build Machine.
-
Choose the project's configuration type: Dynamic Library, Static Library or Application (in this example, Application).
-
Add additional library dependencies on the Linker > Input property page.
-
Pass additional pre-launch commands to the debugger to do things like launch graphical apps on the remote linux machine by specifying export DISPLAY=:0.0
Hitting the F5 key should run the application on the host machine and show the output in the Linux Console Window (at the bottom of the screen - if not visible, select the menu options Debug > Linux Console). Also, breakpoints can be set for the debugger in Visual Studio 2022.
Some Notes on Connecting to and Developing with Windows Subsystem for Linux (WSL)
Because Windows uses port 22 for its own SSH implementation, change the SSH port on the WSL machine to another one such as 23. To do this, edit the /etc/ssh/sshd_config file. Change to Port 23
and PasswordAuthentication yes
to work with Visual Studio's Connection Manager.
sudo nano /etc/ssh/sshd_config
sudo systemctl enable ssh
sudo ssh-keygen -A
sudo service ssh restart