This function requires vs2015 and above , here is VS2019 as an example
When installing VS, you need to select linux support. If you have already installed it, you can install it by modifying VS.
specific process:
First, create a new project
, select the Linux console application,
select the location and name, and then create
it. In this way, our project will create a main file with the content:
#include <cstdio>
int main()
{
printf("%s 向你问好!\n", "ThreadPool");
return 0;
}
Click here to add a remote connection
. Note that linux needs to have ssh service, just fill in normally.
I am connected to Alibaba Cloud here. Note that you need to obtain Alibaba Cloud’s external network ip , so that you can connect smoothly.
Note: The remote connected linux should have gdb, if not, use the package manager to install (apt-get under Ubuntu, yum under CentenOS) to
download and install:
sudo apt-get install gdb
Next, you need to make some settings for this connection.
Tools->Options must be ticked, and then click Update (download for the first time), so that you can write codes to have intelligent prompts. Then you will download and
update the header and wait for it to complete. Then you can
check the properties window.
There are a bunch of settings in it, which can be set as needed . You can
see the remote root directory .
Try to run this project.
Let’s run this project after setting a breakpoint.
You can see that the running results have been displayed. Spicy~
View the written program on the linux side.
Our remote root directory is ~/projects.
Let's go to this location to check.
This is our project, and then proceed to another layer.
You can see the main.cpp file. bin is the directory of the executable program, and obj is the cache file.
After that, you can freely use VS to (remotely) write linux programs~