VS コードでコードをデバッグするときの「起動: プログラム 'c: \build\Debug\outDebug' が存在しません」の解決策

vs code でコードを開発する場合、図に示すように、実行中またはデバッグ中に「起動: プログラム 'c: \build\Debug\outDebug' が存在しません」という問題が発生することがあります。

 ここでは、プロンプトに従って「launch.json」を開きます。

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": true,
      "cwd": "c:/Users/13967/Desktop/c/output",
      "program": "c:/Users/13967/Desktop/c/output/build/Debug/outDebug/",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

観察した結果、問題はプログラムに現れるはずであることがわかりました

"program": "c:/Users/13967/Desktop/c/output/build/Debug/outDebug/",

コードの具体的な場所はここにありますが、この場所は十分正確ではありません。

図のように、私が書いたC言語コードのコンパイル結果は「C:\Users\13967\Desktop\c\output」に格納されています。

「launch.json」の「c:/Users/13967/Desktop/c/output/build/Debug/outDebug/」の代わりに

したがって、まずファイルの場所をコンピューター上の C 言語のコンパイル結果が保存されているフォルダーに変更し、最後に「${fileBasenameNoExtension}.exe」の行を追加して、特定の .exe アプリケーションを見つける必要があります。

私のコンピューターを例に挙げると、最終的に次のように変更しました。

"program": "c:/Users/13967/Desktop/c/output/${fileBasenameNoExtension}.exe",

問題は無事解決しました!図に示すように、コードではすでにブレークポイントを設定してデバッグできます。

 

参考文献:

Maxwell Ape の CSDN ブログ

マイクロソフトの Q&A コミュニティ

おすすめ

転載: blog.csdn.net/antonymbaobwang/article/details/132203511