[Reserved] Visual Studio Code to build C / C ++ development environment

https://www.cnblogs.com/XieSir/articles/8288051.html

 

1. Install  MinGW Distro  /  MinGW  /  the GNU GCC  any one of, (VS Code under Windows does not support CLang).

2. Install the  VS Code

3. Ctrl + Shift + X to install  C / C ++ (cpptools)  plug-in

4. Ctrl + Shift + X installation  Code Runner  widget

5. Restart VS Code, allows the installation of plug-ins to take effect

6. Create a project in the operating system directory, such as "cppProject", and then start the VS Code, open the empty directory

7. Create a source with VS Code hello.cpp file directory in cppProject

8. Add header file path index

In hello.cpp, you will find the header files that include the following line with a green wavy line represents the VS Code of C / C ++ plug-in header files could not find the appropriate path. Move your mouse over this line clicked, a prompt will appear yellow light bulb symbol, click on it, then click "Edit" includePath "setting" button will generate and open c_cpp_properties.json file, edit json file, add the C / C ++ path header files into it. MinGW herein include path is: "C: / MinGW / include / *", add it to the "includePath" and "browse / path" variable.

Also added "--target = x86_64-w64-mingw" tasks.json in the "tasks / args" of.

9. Set build environment  (Code Runner plug installed, then this function is no longer provided)

In VS Code Click hello.cpp back hello.cpp file, call the shortcut Ctrl + Shift + B to build the executable file. At this point VS Code will complain, the top bar in the VS Code display "No task runner configured", you only need to click the blue button to the right of the "Configure task runner" to edit tasks.json can generate. Creates and opens a tasks.json profile select, modify the command and args variable and save:

"command": "g++ "

"args": [ "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}.exe", "--target=x86_64-w64-mingw", "-std=c++17" ]

Guess you like

Origin www.cnblogs.com/sui84/p/11444540.html
Recommended