VS Code官网,支持多平台。
https://code.visualstudio.com/
下面是windows平台的
Download VS Code & Mingw-w64
- https://aka.ms/win32-x64-user-stable
- https://sourceforge.net/projects/mingw-w64/files/latest/download
VS Code安装步骤:
- 1,运行VSCode,默认安装。
- 2,启动VSCode,文件->打开文件夹,选择一个文佳夹作为工作空间。
- 3,查看->扩展,选择Microsoft的C/C++扩展,install。
- 4,还可以安装一个C++ Intellisence扩展。
安装编译环境Mingw-w64
- 1,运行Mingw-w64。NOTE: 以管理员身份安装,需要联网安装。
- 2,将下列路径添加到环境变量的path中:电脑->右键->属性->高级系统设置->环境变量;选择系统变量->编辑->新建,paste下面的实际路径,然后一路确定
- C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
- 3,打开命令窗口,键入gcc可以测试gcc是否可用。
如果在线安装有问题,可以尝试下载离线版,然后解压缩,之后的配置同上。离线版下载链接:
Ctrl R键盘快捷键设置
s下载三个json文件,放到VS Code代码文件夹的子文件夹.vscode下。
Add Keyboard shortcuts so Ctrl R compiles and runs the current program you have open and Ctrl Shft R compiles and runs all programs in your working folder.
- 1,文件->首选项->键盘快捷方式
- 2,打开键盘快捷方式(JSON)
- 3,粘贴keybindings.json文件的内容。
现在可用Ctrl+r来运行程序了。If get this error You need to select your terminal window default shell to be command prompt。
Debug设置
- 1,打开launch.json,在"miDebuggerPath"项中更新gdb.exe的目录。
- 2,设置"externalConsole": false, 以便在VS Code的内嵌终端显示控制台信息。
Set Up C++ With Visual Studio Code (VS Code) on Windows 10 mingw-w64 (Easiest)
Step-by-step instructions PDF:
JSON files required for the installation (zip file):