Using Visual Studio 2017 as a linux c + + development tool

Time:2022-1-7

Visual Studio 2017

The official version of Microsoft’s universe first ide visual studio 2017 has been released. The address is:https://www.visualstudio.com/vs/whatsnew/

Vs2017 has many highlights, including modular installation, faster startup (more than 50% faster for the first startup), GitHub plug-in, improvement of startup page, enhancement of code prompt function, etc. for more reference:https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes

Visual Studio 2017 Support for Linux Development

Vs2017 can edit, compile and debug C + +, Python and node on Linux JS program (detailed).

You can even compile and debug Net program, supported Linux platforms include:

CentOS 7.1 and Oracle Linux 7.1

Debian 8

Fedora 23

Linux Mint 17

openSUSE 13.2

Red Hat Enterprise Linux 7.2

Ubuntu 14.04 and 16.04

Bloggers mainly use C + + as the development language, and most of the code has cross platform requirements. The general steps of bloggers are as follows:

Using visual studio to develop most algorithm function modules on windows machine, and debugging and optimization are completed; When it comes to IO or network related parts, you need to port to the Linux platform, painfully write code with VIM, compile with GCC, and debug with GDB.

Focus on the highlight of visual studio in C + + cross platform, that is, Visual C + + for Linux. With it, you can use the most advanced IDE for cross platform development. How happy!

Visual C++ for Linux

VC + + 2017 supports writing and debugging C + + programs under Linux ([details](https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/))。

Create a cross platform linux c + + program, as shown in the figure:

The actual use effect is shown in the figure below. It can be seen that Linux code can be compiled under vs, even including Linux specific header files. In addition to code completion, it also has the advantages of code coloring, visual debugging and so on.


Use steps

1. Install the compilation environment and debugging environment on the target Linux machine, such as openssh server / G + + / GDB / GDBSERVER under Ubuntu.

sudo apt-get install openssh-server g++ gdb gdbserver

2. After installing visual studio 2017 on this computer, you need to choose to install cross platform linux c + + environment.

3. Open visual studio, create a new project, and select cross platform / Linux / console application.

4. Before the first build, SSH will be required to connect to the target Linux machine, fill in the user name and password to connect to the target machine. If the target machine address needs to be changed, it can be managed under tools / options / cross platform.

5. Set a series of options (in BOLD), which are basically consistent with the settings of ordinary Win32 programs. Note the following 2 points:

Vs will not automatically copy the header file in the additive include to the local for code completion prompt. You need to manually copy / usr / include, / usr / local / include and other directories under Linux to the Linux header path of vs (such as C: \ program files (x86) \ Microsoft Visual Studio \ 2017 \ community \ common7 \ ide \ VC \ Linux \ include \ USR)

The header file containing directory and library file containing directory are absolute paths under Linux.





6. During compilation vs, the code will be copied to the ~ / projects / [project name] directory of the target machine, and the binary file is in the bin directory of its directory. As shown in the figure below, you can see that there is already code in the Linux environment.


Actual development

In the initial use experience, I feel that this vs for Linux is not particularly mature, and there are many problems, including: the speed of copying files is too slow, multi-threaded compilation is not possible, the compilation output information is lost (not friendly enough), and the springboard machine cannot be operated.

However, as an auxiliary tool for coding, the tool is still very valuable. It combines vs powerful code editing and debugging functions with the natural server characteristics of Linux machine. The future can be expected!

More articles, seehomepage

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.

Recommended Today

Network counting experiment I Division VLAN

Experiment 1  vlanCreation and division of 1、 Experiment purpose: 1. Understand the working principle of VLAN; 2. Learn the method of dividing VLANs based on ports; 3. Understand the communication between the same VLANs across switches; 4. Further learn the configuration commands of switch ports. 2、 Experimental principle: VLAN (virtual local area network), that is, […]