在vs code開發(fā)代碼的途中,我們可能會在運行或調(diào)試的途中碰到“l(fā)aunch: program ‘c: \build\Debug\outDebug‘ does not exist”的問題,如圖所示。
?這里我們按照提示打開“l(fā)aunch.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
}
]
}
]
}
經(jīng)過觀察,我發(fā)現(xiàn)問題應(yīng)當出現(xiàn)在program里
"program": "c:/Users/13967/Desktop/c/output/build/Debug/outDebug/",
這里定位到了代碼的具體位置,但是這個位置不夠準確。
如圖,我寫的C語言代碼的編譯結(jié)果都儲存在“C:\Users\13967\Desktop\c\output”里面。
而不是“l(fā)aunch.json”中的"c:/Users/13967/Desktop/c/output/build/Debug/outDebug/"
因此我們首先要將文件位置改成自己電腦中存放C語言編譯結(jié)果的文件夾,然后再在后面加上一行“${fileBasenameNoExtension}.exe”用于定位具體的.exe應(yīng)用程序。
以我的電腦為例,最后改成這樣:
"program": "c:/Users/13967/Desktop/c/output/${fileBasenameNoExtension}.exe",
問題成功解決!如圖所示代碼已經(jīng)可以設(shè)置斷點并且進行調(diào)試力。
?
參考資料:
麥克斯韋猿的CSDN博客文章來源:http://www.zghlxwxcb.cn/news/detail-730863.html
Microsoft的Q&A問答社區(qū)文章來源地址http://www.zghlxwxcb.cn/news/detail-730863.html
到了這里,關(guān)于在VS code中調(diào)試代碼出現(xiàn)“l(fā)aunch: program ‘c: \build\Debug\outDebug‘ does not exist”的解決方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!