#include
int main()
{
printf("hello word\n");
return 0;
}
launch.json代码:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\mingw\mingw\bin\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 生成活动文件"
}
]
}
tasks.json代码:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "C:\mingw\mingw\bin\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
1.
代码编译错误,渲染层错误
1 launch.json和task.json中路径写错了,你用的是\单斜杠,要用\\双斜杠,或者反斜杠/, "miDebuggerPath": "D:\\mingw-w64\\mingw32\\bin\\gdb.exe"
2如果配置没问题,但还是报错,最大的可能,是不是没有把mingw-w64的bin所在文件夹加入到系统环境变量中?
3如果不知道如何配置mingw环境变量的话,可以直接下载codeblock安装版,会自带Mingw,可以参考我写的教程
https://blog.csdn.net/qq_46207024/article/details/115710608?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165962801816781683939721%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165962801816781683939721&biz_id=0&spm=1018.2226.3001.4450
launch.json和task.json中路径中的斜杠有转义,\要用\\,或者干脆用/,比如:"command": "C:/mingw/mingw/bin/gcc.exe",
返回-1可能是编译失败,你看看输出。
{
"name": "C++",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/exeout/${fileBasenameNoExtension}.exe",
"args": [],
"preLaunchTask": "g++_buld",
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
删掉依赖,重新下载编译就好了