参数含义:
32位系统选择i686, 64位系统选择x86_64
线程模型:win32 : 没有C ++ 11多线程特性, posix : 支持C ++ 11多线程特性
异常处理模型:32位系统推荐dwarf,64位系统推荐seh
因为测试环境为64位系统,所以推荐配置为x86_64-posix-seh
下载完以后解压到你自定义的路径下,将你自定义的路径/mingw64/bin目录添加到系统环境的path下面
新建的项目是没有task.json和launch.json这两个文件的
创建文件的方法: ctrl+shift+p打开命令行
分别输入task和launch两个命令
task.json→作用:构建、编译程
c的配置
c++的配置
{
//the c configuration
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "D:\\Program Files (x86)\\mingw64\\bin\\gcc.exe", //这里换成你的MinGW安装地址
"args": [
"-Wall", // 开启 -Wall 选项
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
], //这里是编译命令参数 gcc -Wall -g -o xx.exe
"options": {
"cwd": "D:\\Program Files (x86)\\mingw64\\bin" //MinGW的bin目录位置
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
{
//the c++ configuration
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "D:\\Program Files (x86)\\mingw64\\bin\\g++.exe", //这里换成你的MinGW安装地址
"args": [
"-Wall", // 开启 -Wall 选项
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
], //这里是编译命令参数 gcc -Wall -g -o xx.exe
"options": {
"cwd": "D:\\Program Files (x86)\\mingw64\\bin" //MinGW的bin目录位置
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
{
//the c configuration
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe", //
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false, // true时,运行时会打开CMD窗口来显示运行结果
"MIMode": "gdb",
"miDebuggerPath": "D:\\Program Files (x86)\\mingw64\\bin\\gdb.exe", //同样要设置为 MinGW 的安装目录内bin/gdb.exe的绝对路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file"
}
]
}
{
//the c++ configuration
"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, // true时,运行时会打开CMD窗口来显示运行结果
"MIMode": "gdb",
"miDebuggerPath": "D:\\Program Files (x86)\\mingw64\\bin\\gdb.exe", //同样要设置为 MinGW 的安装目录内bin/gdb.exe的绝对路径
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file"
}
]
}
设置程序运行在终端
文件→首选项→设置→用户→扩展→run code configuration→run in Terminal前面打勾
具体的项目配置工程模板链接
cpp的工程模板
F5一键编译