Vscode + MinGW configuration C ++ development environment (version too old to resolve slow downloads and online issues)

Ready computer MinGW compiler environment

  1. Why MinGW, supports optional digits, stable, multi-library package, VScode have good support
  2. Why not mingw.org download, mingw older version, there are many versions of the problem, a third-party package problems, and even the standard library problems, because they no longer maintain
  3. Why recommend mingw-64, the new version is the C ++ expand recommend VScode
  4. Why Offline installation package: package download is very slow because the online direct stuck

MinGW-off installation package 64

注意:以上是弥补vscode官方教程的缺陷:mingw-64下载过慢,后文建议看官网 https://code.visualstudio.com/docs/cpp/config-mingw


mingw installation path can not have spaces ~/Program Files/…in spaces, so the default choice of windows path must be changed

Configuring Path environment path

Configuration variables: g ++ exe that tell the computer software compiler in which other software can also be found by accessing the computer's g ++ exe Path where such VScode need to know, with g ++ compile connection optimization.

  1. Find your installation …/mingw-64/, copy the path, the new MinGW system variable, the value is the path
  2. Add a variable in the Path%MinGW/bin%
  3. ok, complete the configuration
  4. By the way, check number, open cmd or powershell, enter g++ -v , print information appears, it shows, cmd this software Path to find the g ++ compiler mingw where we believe it can VScode or other software can also be found MinGW the C ++ compiler

VScode install C / C ++ expand

Configured to run (most direct configuration is automatically generated VSCODE)

  1. Write a C ++ executable file
    Here Insert Picture Description
    you can write this:
int main(){
	std::cout<<"Test Env"<<std::endl;
  1. From the main menu Terminal> Configure Default Build Task., The map appears, select g ++
    Here Insert Picture Description
  2. You can see the automatically generated
  "version": "2.0.0",
  "tasks": [
      "type": "shell",
      "label": "g++.exe build active file",
      "command": "C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
      "args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
      "options": {
        "cwd": "C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin"
      "problemMatcher": ["$gcc"],
      "group": {
        "kind": "build",
        "isDefault": true

These configurations tell VSCODE relevant information, the most important is compilerPath, this is where g ++ compiler

  1. Press Ctrl + Shift + B shortcut to run some of the above tasks, you will see

Here Insert Picture Description
If you do that grammar correctly, which is compiled successfully, the above task.json configuration is compiled. You will find more than a file directory exe file

  1. Configuring debug
    hit Debug> Add Configuration ...

Here Insert Picture Description
6. Select the generated debug g ++ profile, will generate similar launch.json

  "version": "0.2.0",
  "configurations": [
      "name": "g++.exe build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "miDebuggerPath": "C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gdb.exe",
      "setupCommands": [
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
      "preLaunchTask": "g++.exe build active file"
  1. In this way, you will be able to run the debugger, and so far successful installation environment
    Here Insert Picture Description
Published 24 original articles · won praise 23 · views 10000 +

Guess you like

Origin blog.csdn.net/TowerOs/article/details/104234734