看了就会的VScode给C++的配置编译环境(Visual Studio Code)
我看了网上的大佬们配的我是在是看不懂啊?我是一个小白啊?这太难了,这阻挡不了我,想使用这很骚的IDE,于是在不断的摸索下,终于配置成功,小白们也不用慌,这次非常简单。一定可以的。
1.下载 VS Code
下载网址:https://code.visualstudio.com/
2.运行安装程序
一定不要忘记把Path那一条点上。
3.装MinGW
当时我下了半天找不到,这次我放个地址,github放不下这么大的文件,传文件夹的话还得ssh啥的,还不会,将就一下https://share.weiyun.com/5jhqiln
下载完了直接放到C盘根目录下,没多大,只有600M,这样的话,就不用改我配置的路径什么的了!
这样就完事了,然后是配置环境变量。
4.环境变量
会配的直接跳过即可
找到这两个path,用户和系统变量。
点击新建,然后输入 C:\MinGW\bin
这样环境变量就配置完了
检查 win+R cmd 输入 gcc -v
这样就配完了
5.倒数第二步
下载地址,解压出来 https://github.com/DuYuren/MinGW/tree/vscode
建个文件夹随便什么名字
把我的 .vscode 放里面
6.最后一步
然后在刚才那个文件夹里写个C++文件,就可以编译了,F5呦。
如果想在CMD运行,而不启动编译调试的话我们接着整活
要是配置C++ 编译环境,这边走
用了VScode童鞋,都知道,写C++是不保留窗口的,除非打上断点或者:
system("pause");
这里给大家分享一种不需要,F5或者Ctrl+F5的方法,可以使用VScode保留CMD窗口,方法非常简单,当然我的配置方法也非常简单。
这里这里
这里进入正题:
安装插件
配置插件
完事了,就这么简单,编译很快,不过没有Debug,想Debug还是F5,没有影响的,直接编译运行是F6,完事,完事撒花。
如果纯粹是来找json文件的
大佬们改改位置就能用
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/MinGW/include/*"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/MinGW/bin/gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"miDebuggerPath": "c:\\MinGW\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"externalConsole": true,
"preLaunchTask": "g++"
}
]
}
settings.json
{
"files.associations": {
"vector": "cpp",
"random": "cpp",
"iostream": "cpp",
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cuchar": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"map": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"scoped_allocator": "cpp",
"shared_mutex": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
},
"editor.fontFamily": "Consolas, 'Fira code', monospace",
"C_Cpp.errorSquiggles": "Disabled"
}
tasks.json
{
"version": "2.0.0",
"command": "g++",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
},
"args": ["-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
写在最后:
我叫风骨散人,名字的意思是我多想可以不低头的自由生活,可现实却不是这样。家境贫寒,总得向这个世界低头,所以我一直在奋斗,想改变我的命运给亲人好的生活,希望同样被生活绑架的你可以通过自己的努力改变现状,深知成年人的世界里没有容易二字。目前是一名在校大学生,预计考研,热爱编程,热爱技术,喜欢分享,知识无界,希望我的分享可以帮到你!
如果有什么想看的,可以私信我,如果在能力范围内,我会发布相应的博文!
感谢大家的阅读!😘你的点赞、收藏、关注是对我最大的鼓励!