当前位置:   article > 正文

VsCode环境配置_vscode配置环境变量

vscode配置环境变量

1.下载VsCode安装包以及MINGW文件

链接:https://pan.baidu.com/s/13bmi22264pP_8Cojo2FRGQ 
提取码:d416

2.将MinGW.zip解压放到自定义的目录中,例如下图作参考

 

3.配置编译环境变量,电脑-属性-高级系统设置-环境变量-系统变量,找到Path路径,添加MinGW\bin和MinGW\include

4.傻瓜式安装vscode后,先新建一个文件夹,再用vscode打开文件夹

如果没有右键Open with Code,就新建一个test.reg文件,然后把下面代码复制到该文件,将vscode的路径【E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe】替换为自己的安装路径,保存,双击就行

  1. Windows Registry Editor Version 5.00
  2. [HKEY_CLASSES_ROOT\*\shell\VSCode]
  3. @="Open with Code"
  4. "Icon"="E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe"
  5. [HKEY_CLASSES_ROOT\*\shell\VSCode\command]
  6. @="\"E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
  7. Windows Registry Editor Version 5.00
  8. [HKEY_CLASSES_ROOT\Directory\shell\VSCode]
  9. @="Open with Code"
  10. "Icon"="E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe"
  11. [HKEY_CLASSES_ROOT\Directory\shell\VSCode\command]
  12. @="\"E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""
  13. Windows Registry Editor Version 5.00
  14. [HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode]
  15. @="Open with Code"
  16. "Icon"="E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe"
  17. [HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode\command]
  18. @="\"E:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""

5.在该文件夹下新建一个cpp文件,写个简单的测试程序就行

  1. /*
  2. * @Author: your name
  3. * @Date: 2021-07-31 00:12:45
  4. * @LastEditTime: 2021-08-02 00:31:20
  5. * @LastEditors: DESKTOP-EN3DD6F
  6. * @Description: In User Settings Edit
  7. * @FilePath: \C++\HelloWorld .cpp
  8. */
  9. #include <iostream>
  10. using namespace std;
  11. int main(int argc, char** argv)
  12. {
  13. cout << "Hello World" <<endl;
  14. getchar();
  15. return 0;
  16. }

6.插件搜索C++插件安装

7.F5后选择第一项如图

 弹框后继续选择第一项

会生成lanch.json和tasks.json文件

lanch.json

  1. {
  2. // 使用 IntelliSense 了解相关属性。
  3. // 悬停以查看现有属性的描述。
  4. // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  5. "version": "0.2.0",
  6. "configurations": [
  7. {
  8. "name": "g++.exe - 生成和调试活动文件",
  9. "type": "cppdbg",
  10. "request": "launch",
  11. "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
  12. "args": [],
  13. "stopAtEntry": false,
  14. "cwd": "${fileDirname}",
  15. "environment": [],
  16. "externalConsole": false,
  17. "MIMode": "gdb",
  18. "miDebuggerPath": "E:\\tower\\MinGW\\bin\\gdb.exe",
  19. "setupCommands": [
  20. {
  21. "description": "为 gdb 启用整齐打印",
  22. "text": "-enable-pretty-printing",
  23. "ignoreFailures": true
  24. }
  25. ],
  26. "preLaunchTask": "C/C++: g++.exe 生成活动文件"
  27. }
  28. ]
  29. }

tasks.json

  1. {
  2. "tasks": [
  3. {
  4. "type": "cppbuild",
  5. "label": "C/C++: g++.exe 生成活动文件",
  6. "command": "E:\\tower\\MinGW\\bin\\g++.exe",
  7. "args": [
  8. "-g",
  9. "${file}",
  10. "-o",
  11. "${fileDirname}\\${fileBasenameNoExtension}.exe"
  12. ],
  13. "options": {
  14. "cwd": "${fileDirname}"
  15. },
  16. "problemMatcher": [
  17. "$gcc"
  18. ],
  19. "group": {
  20. "kind": "build",
  21. "isDefault": true
  22. },
  23. "detail": "调试器生成的任务。"
  24. }
  25. ],
  26. "version": "2.0.0"
  27. }

 8.配置lanch.json externalConsole属性为true。保存后F5,运行成功

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号