vscode configure c/c++ compilation environment

One, install vscode

Official website download

Two, install the plug-in and configure the c\c++ compilation environment

1. Install the following two plugins

image-20210318215828521

2. Configure the compilation environment

One, install mingw64 (recommended)

method one

  1. It is recommended to use the mingw64 of devc++ to find the installation directory of devc++ and open it to find

  2. Configure environment variables

  3. verificationimage-20210318173237138

    image-20210318173325255

Method Two

Download and install mingw64 from the official website (not recommended, anyway, I failed). If you don't want to use devc++, you can download and install first, copy mingw64 to the specified location and configure environment variables for it, and then uninstall devc++.

image-20210318174232959

image-20210318174357916

The verification method is the same as above

2. If you have installed visual studio, you can use Microsoft's msvc

Still not recommended, but you can try

3. Write the configuration file

  1. Create an empty folder anywhere

  2. Use vscode to open the folder and write a hello.cpp

    #include <iostream>
    
    using namespace std;
    
    int main() {
        cout << "hello world";
        return 0;
    }
    
  3. ctrl + shift + p

    1. Editor pathimage-20210318180659426

    2. IntelliSense modeimage-20210318180922832

    3. At this time, there will be an extra .vscode folder in the directoryimage-20210318181301099

    4. Open hello.cpp, enter ctrl + shift + p , and create an extra file named tasks.json in the .vscode folderimage-20210318181439350

    5. image-20210318181941988

      image-20210318182103645

      image-20210318182129450

      Found another file launch.json under .vscode, change it as follows

      image-20210318182334042

4. Test ctrl + F5

Found that the console window flashed by, in fact, it has been successful, if you want to stop it, you can add a cin statement

At this point, we can save the .vscode folder and copy it directly when needed (in fact, the operation is very simple, almost no changes, you can use the above steps)

Attach my .vscode folder, if it is unsuccessful, you can change the path with cv

c_cpp_properties.json
launch.json
tasks.json

Guess you like

Origin blog.csdn.net/weixin_49094787/article/details/114992035
Recommended