https://blog.csdn.net/m0_49419631/article/details/122894447?spm=1001.2101.3001.6650.15&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-15-122894447-blog-118950592.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-15-122894447-blog-118950592.pc_relevant_default&utm_relevant_index=16 寫下此文主要是為了方便我以后在配置環(huán)境時(shí)來(lái)進(jìn)行查看,我希望能幫助到需要的人。 目錄: 1.下載安裝VSCode 2.下載安裝c/c++編譯插件 3.安裝編譯,調(diào)試環(huán)境 4.添加系統(tǒng)環(huán)境變量Path 5.修改vscode 調(diào)試配置文件 6.其他
1.下載安裝VSCode
1.1VSCode下載官網(wǎng):https://code./Download。 1.2Windows10系統(tǒng)選擇紅色標(biāo)記的下載即可。 1.3雙擊安裝即可
2.下載安裝c/c++編譯插件
2.1點(diǎn)擊左邊紅色框標(biāo)記的圖標(biāo),然后再搜索框中搜索并下載中文語(yǔ)言包和C/C++編譯插件
3.安裝編譯,調(diào)試環(huán)境
3.1MinGW-w64離線安裝包下載官網(wǎng) https:///projects/mingw-w64/files/mingw-w64/mingw-w64-release/ 3.2點(diǎn)擊下載紅色框標(biāo)記的安裝包 3.3然后解壓安裝包并修改地址
4.添加系統(tǒng)環(huán)境變量Path
4.1添加系統(tǒng)環(huán)境變量,所添加地址即為MinGW壓縮包解壓后的地址
5.修改vscode 調(diào)試配置文件
5.1 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", // 配置名稱,將會(huì)在啟動(dòng)配置的下拉菜單中顯示
"type": "cppdbg", // 配置類型,這里只能為cppdbg
"request": "launch", // 請(qǐng)求配置類型,可以為launch(啟動(dòng))或attach(附加)
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",// 將要進(jìn)行調(diào)試的程序的路徑
"args": [], // 程序調(diào)試時(shí)傳遞給程序的命令行參數(shù),一般設(shè)為空即可
"stopAtEntry": false, // 設(shè)為true時(shí)程序?qū)和T诔绦蛉肟谔?,一般設(shè)置為false
"cwd": "${workspaceFolder}", // 調(diào)試程序時(shí)的工作目錄,一般為${workspaceFolder}即代碼所在目錄
"environment": [],
"externalConsole": true, // 調(diào)試時(shí)是否顯示控制臺(tái)窗口,一般設(shè)置為true顯示控制臺(tái)
"MIMode": "gdb",
"miDebuggerPath": "S:\\MinGW\\bin\\gdb.exe", // miDebugger的路徑,注意這里要與MinGw的路徑對(duì)應(yīng)
"preLaunchTask": "g++", // 調(diào)試會(huì)話開始前執(zhí)行的任務(wù),一般為編譯程序,c++為g++, c為gcc
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
5.2 tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++", //這里注意一下,見下文
"command": "S:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "S:\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
]
}
]
}
5.3 c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\**",
"S:\\MinGW\\include\\*",
"S:\\MinGW\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\*",
"S:\\MinGW\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\ssp\\*",
"S:\\MinGW\\lib\\gcc\\x86_64-w64-mingw32\\8.1.0\\include\\*"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "S:\\MinGW\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
|