VSCode + MinGW-64 で Cのコードをビルド&デバッグ
解決したいこと
VSCode + MinGW-64 で C のコードをビルド&デバッグしようとしています。
ビルドは正常に完了しました。と表示されるのですが、デバッグを行うと、下の画像のようなエラーが表示されます。
tasks.jsonとlaunch.jsonを何度か修正を行ったのですが、エラーの表示が消えずデバッグを行うことが出来ません。
どのような処理を行えばよいのか解決方法を教えて頂きたいです。
発生している問題・エラー
該当するソースコード launch.json
{
// IntelliSense を使用して利用可能な属性を学べます。
// 既存の属性の説明をホバーして表示します。
// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - build & debug",
"type": "cppdbg",
"request": "launch",
"program": "C:\\Users\\name\\OneDrive\\Desktop\\geology\\A-5.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/Users/name/OneDrive/Desktop/geology",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath":"C:/Program Files (x86)/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file" // ★重要!
}
]
}
該当するソースコード task.json
{
"version": "2.0.0",
"configurations": [
{
"name": "gcc.exe - build & debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:/Program Files (x86)/mingw64/bin/gdb.exe",
"setupCommands": [
{
"description": "gdb の再フォーマットを有効にする",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe アクティブなファイルのビルド"
}
],
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe アクティブなファイルのビルド",
"command": "C:\\Program Files (x86)\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "デバッガーによって生成されたタスク。"
}
]
}
自分で試したこと
https://qiita.com/yamazaki3104/items/91cabd58980c6c17754e?utm_source=pocket_mylist
を参考に修正を行いましたが、初心者であることから正しく修正が行えたかどうかが不明です。
0