windows 配置C++环境
生活随笔
收集整理的這篇文章主要介紹了
windows 配置C++环境
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 安裝vscode
- 安裝mingw
- 配置環境變量
- 配置.cpp環境
- 編輯 launch.json 配置文件
- 返回.cpp文件,按F5進行調試,會彈出找不到任務"task g++",選擇 "配置任務",會自動生成 tasks.json 文件
- 編輯 tasks.json 文件
安裝vscode
安裝mingw
下載地址:https://sourceforge.net/projects/mingw-w64/files/
下載的文件:進入網站后不要點擊 “Download Lasted Version”,往下滑,找到最新版的 “x86_64-posix-seh”。
安裝MinGW:下載后是一個7z的壓縮包,解壓后移動到你想安裝的位置即可。我的安裝位置是:D:\2Software\mingw64
配置環境變量
配置.cpp環境
新建 test.cpp文件
#include <stdio.h> #include <windows.h> int main() {printf("Hello World\n");system("pause");return 0; }進入調試界面添加配置環境,選擇 C++(GDB/LLDB),再選擇 g++.exe,之后會自動生成 launch.json 配置文件
編輯 launch.json 配置文件
{"version": "0.2.0","configurations": [{"name": "g++.exe build and debug active file","type": "cppdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": true, //修改此項,讓其彈出終端"MIMode": "gdb","miDebuggerPath": "C:\\mingw64\\bin\\gdb.exe","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "task g++" //修改此項}] }返回.cpp文件,按F5進行調試,會彈出找不到任務"task g++",選擇 “配置任務”,會自動生成 tasks.json 文件
編輯 tasks.json 文件
{"version": "2.0.0","tasks": [{"type": "shell","label": "task g++", //修改此項"command": "C:\\mingw64\\bin\\g++","args": ["-g",//"-fexec-charset=GBK", // 處理mingw中文編碼問題"-finput-charset=UTF-8",// 處理mingw中文編碼問題//"${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "C:\\mingw64\\bin"},"problemMatcher": ["$gcc"],"group": "build"}] }總結
以上是生活随笔為你收集整理的windows 配置C++环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu自动提醒
- 下一篇: mp4文件时长 c++源码_【C语言】如