linux配置vscodec运行环境,Linux 下 VSCode c/c++环境配置
8種機(jī)械鍵盤軸體對(duì)比
本人程序員,要買一個(gè)寫代碼的鍵盤,請(qǐng)問(wèn)紅軸和茶軸怎么選?
切換中文
安裝完成的VSCode是英文的,作為一個(gè)英文不好的中國(guó)人,我還是喜歡看中文的接口。
點(diǎn)擊左側(cè)的
會(huì)進(jìn)入擴(kuò)展商店
拓展商店中直接搜索Chinese 然后點(diǎn)擊Install就行
安裝完成后重啟應(yīng)用就會(huì)變成中文接口。
安裝插件
Code Runner
安裝完成后窗口菜單欄下面就會(huì)出來(lái)一個(gè)
當(dāng)你的顯示頁(yè)面是一個(gè)進(jìn)程源文檔(單個(gè)文檔,不是項(xiàng)目)時(shí),點(diǎn)擊這個(gè)按鈕或者按ctrl+F5就可以直接運(yùn)行這個(gè)進(jìn)程,方便快捷。
點(diǎn)擊齒輪,點(diǎn)擊配置,然后把右側(cè)的Run In Terminal勾上,就會(huì)在控制面板顯示運(yùn)行結(jié)果
c/c++
必裝的插件。
C++ Intellisense
C++的只能提示工具
C/C++ Clang Command Adapter
提供靜態(tài)檢測(cè)(Lint)
配置環(huán)境
主要是連個(gè)json文檔
launch.json
點(diǎn)擊調(diào)試,然后選擇添加配置。會(huì)自動(dòng)生成lanunch.json文檔
這是我的配置,可以直接復(fù)制過(guò)去
要注意的就是
"program": "${workspaceFolder}/hello.out", //當(dāng)前目錄下編譯后的可執(zhí)行文檔"build"`1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32這里的hello.out應(yīng)該是你生成的執(zhí)行文檔,而build 應(yīng)該是你的tasks的lable
```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug cpp", //名稱
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/hello.out", //當(dāng)前目錄下編譯后的可執(zhí)行文檔
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}", //表示當(dāng)前目錄
"environment": [],
"externalConsole": false, // 在vscode自帶的終端中運(yùn)行,不打開外部終端
"MIMode": "gdb", //用gdb來(lái)debug
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build" //執(zhí)行l(wèi)anuch之前運(yùn)行的task
}
]
}
tasks.json
按住ctrl+shift+p
輸入tasks,選擇configure Task
選擇使用模板創(chuàng)建然后選others
就會(huì)生成tasks.json文檔
仍舊可以直接拷貝
參數(shù)應(yīng)該是自己的,多個(gè)文檔編譯,和在bash中寫一樣,也可以用makefile1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build", // task的名字
"type": "shell",
"command": "g++", //編譯命令
"args": [ //編譯參數(shù)列表
"hello.cpp",
"-o",
"hello.out"
]
}
]
}
c_cpp_properties.json
ctrl+shift+p 輸入c/c++:Edit Configurations 選擇這一項(xiàng)就可以創(chuàng)建一個(gè)c_cpp_properties.json文檔
不用改動(dòng),我也貼出來(lái)我的配置1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
如果有自己的外鏈庫(kù)也是添加到這里面。
總結(jié)
以上是生活随笔為你收集整理的linux配置vscodec运行环境,Linux 下 VSCode c/c++环境配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 解决sublime text无法安装插件
- 下一篇: html人物动画效果图,9款用HTML5