1. Download MinGW compiler
- The difference between IDE and compiler
IDE (integrated development environment) is an application program used to provide a program development environment. It generally includes tools such as editor, compiler, debugger and graphical user interface. It is a development software suite
Compiler: converts one language (usually high-level language, such as C + +) into another language (usually low-level language, such as coding language). The general workflow is: Source code – > preprocessor - > compiler – > object code - > linker – > executable program (. exe)
Editor: text editing software. Theoretically, any kind of editor can write code, but the use of special code editing software will speed up the efficiency
- Try to download version 8 10 MinGw editor (now 2021 / 8 / 30, the latest version is 9), but the new version is not stable and changes greatly. It is recommended to install version 8 editor
Go to https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
Turn this address down
2. After installation, copy the Path from bin to Path
3. Download vscode. Vscode plug-ins are usually downloaded. You can supplement them later according to the situation. The three are generally Chinese, C/C + + and C/C++ Compile
4. Disposition
We set up a large folder TEST [the external chain picture transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-mmce9tp5-1630291627525) (C: \ users \ 33385 \ appdata \ roaming \ typora \ user images \ image-20210830103343936. PNG)]
Create three new files in it
- launch. The code in JSON is:
{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", // The configuration name will be displayed in the drop-down menu of startup configuration "type": "cppdbg", // Configuration type, which can only be cppdbg "request": "launch", // Request configuration type, which can be launch or attach "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe", // The path to the program that will be debugged "args": [], // The command line parameters passed to the program during program debugging are generally set to null "stopAtEntry": false, // When set to true, the program will pause at the program entrance, which is generally set to false "cwd": "${workspaceFolder}", // The working directory when debugging the program is generally ${workspaceRoot}, that is, the directory where the code is located, workspaceRoot, has been abandoned and is now changed to workspaceFolder "environment": [], "externalConsole": true, // Whether to display the console window during debugging. It is generally set to true to display the console "MIMode": "gdb", "miDebuggerPath": "C:/Program Files/mingw-w64/mingw64/bin/gdb.exe", // The path of miDebugger. Note that it corresponds to the path of MinGw "preLaunchTask": "g++", // The tasks executed before the start of the debugging session are generally compilers, c + + is G + +, and c is gcc "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": false } ] } ] }
Just change the address here to the previous bin folder location
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (IMG suvcywml-1630291627529) (C: \ users \ 33385 \ appdata \ roaming \ typora \ typora user images \ image-20210830103633993. PNG)]
- tasks.json can be copied directly
{ "version": "2.0.0", "command": "g++", "args": [ "-g", "${file}", "-o", "${fileBasenameNoExtension}.exe" ], // Compile command parameters "problemMatcher": { "owner": "cpp", "fileLocation": [ "relative", "${workspaceFolder}" ], "pattern": { "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$", "file": 1, "line": 2, "column": 3, "severity": 4, "message": 5 } } }
- c_cpp_properties.json
First open win + r for operation, then enter cmd, and then enter gcc -v -E -x c + + - in cmd. If a pile of version information appears (as shown in the figure), code 1 is adopted; if not, code 2 is adopted
Code 1:
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceRoot}", "C:/Program Files (x86)/mingw64/include/**", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include" ], "defines": [ "_DEBUG", "UNICODE", "__GNUC__=6", "__cdecl=__attribute__((__cdecl__))" ], "intelliSenseMode": "msvc-x64", "browse": { "limitSymbolsToIncludedHeaders": true, "databaseFilename": "", "path": [ "${workspaceRoot}", "C:/Program Files (x86)/mingw64/include/**", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include" ] } } ], "version": 4 }
Code 2:
{ "configurations": [ { "name": "Win32", "includePath": [ "C:/Program Files (x86)/mingw64/include/**", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed", "C:/Program Files (x86)/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include" ], "browse": { "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" } } ], "version": 4 }
5. We create a middle folder and then create code in the middle folder
[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-3ndlinei-1630291627532) (C: \ users \ 33385 \ appdata \ roaming \ typora \ user images \ image-20210830104442530. PNG)]
6. f5 runs successfully!!!
"databaseFilename": ""
}
}
],
"version": 4
}
5,We create a middle folder and then create code in the middle folder [External chain picture transfer...(img-3NdlineI-1630291627532)] 6,f5 Run, successful!!!