Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure C++ environment for VSCode

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to configure the C++ environment with VSCode". In daily operation, I believe many people have doubts about how to configure the C++ environment with VSCode. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to configure the C++ environment with VSCode". Next, please follow the editor to study!

First, install the software VSCode

Choose the version that suits you, install it yourself, and remember the installation path (leave the back door for future uninstallation). You can choose the default option, or you can choose it by yourself. If you have any problems, you can search and solve them by yourself.

2. Necessary plug-ins

After VSC is installed, you may need to install some plug-ins:

[1] Chinese simplified plug-ins and CCMG + extensions

Also, search for Chinese in the app store and choose to install and restart as shown.

[2] you can also choose other landscaping or programming plug-ins: such as one dark pro, code runner, vscodeicons, etc.

Note: the landlord has installed the Chinese plug-in, so the interface is Chinese at the beginning, the screenshot is not exactly the same in front, just take a look at the reference, the location of the extension store is in the bottom icon on the left, select the recommended column and then search for the plug-ins you need, everything in it.

In addition, the problem of installing plug-ins is also the problem of Sinicization. If there is a problem, you can search and solve it on your own.

Install the Microsoft C + + (MSVC) compiler toolset

If you have the latest version of Visual Studio installed, open Visual Studio Installer from the Windows start menu and verify that the C + workload is selected. If not, check the box and click the modify button in the installer.

Ps: the landlord already has visual studio2019, so it is not installed separately. Install it according to Microsoft's official documentation. I won't repeat it.

IV. Start configuration

(1) start VS Code from Developer Command Prompt

  1. First of all, it is recommended to create an empty project folder in a folder on the system disk (usually disk C). We name it "projects" and create a subfolder called "helloworld" in this empty folder.

(for example, the path of C:aMyDocumentsprojects must be in English.)

Now we need to copy the path of this file (after opening the helloworld folder, copy it in the address bar, the personal example is shown in the figure:) (so the address I copied is: C:aMyDocumentsprojectshelloworld)

  2. To open the developer command prompt for VS, type "Developer" in the start menu of Windows, and you should see it appear in the list of suggestions. (the name depends on the version of Visual Studio you installed)

* * Please select the right-click administrator to open it, which will save a lot of trouble in the future. * *

3. We need to enter the subfolder named "helloworld" at the developer command prompt, and then open the folder with VSC, as follows:

After opening the developer command prompt for Visual Studio, type

Cd+ space + the address you just copied + enter, and then the cursor automatically jumps to the next line, and you type:

Code+ space +. + enter and then automatically open VSC.

Note:

1. The plus sign of the above command does not need to be entered

2. There is a point at the end of the second command. Note that it is in English.

3 lowercase for English

Explanation:

1. The cd above means to transfer the path of the command prompt to the helloworld folder you created earlier

2. The second command means to open the helloworld folder with VSC.

PS:

You also need to do this if you write C++ in other places in the future, so you need to remember this cd command (and I don't know if for some reason my computer can only cd to disk C, but not other disks, so it's best to put files on disk C, what you can remember, and in a non-Chinese folder).

To use MSVC in VSC, you must start VSC from the developer command prompt of Visual Studio. The normal Windows command prompt or Bash prompt does not set the necessary environment variables. (or is there a boss who can teach you how to set it up?)

From now on, every time you start, you have to enter from here.

(2) write to C++ document

The left side of the VSC that opens automatically is shown in the figure:

Click helloworld folder-- > > Click New File-- > > enter helloworld.cpp (note that the suffix .cpp must be added)-- > > then type the following C++ code on the right (you can also write it yourself):

# include # include # include using namespace std;int main () {vector msg {"Hello", "C++", "World", "from", "VS Code!"}; for (const string& word: msg) {cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report