900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > linux配置vscodec运行环境 Linux 下 VSCode c/c++环境配置

linux配置vscodec运行环境 Linux 下 VSCode c/c++环境配置

时间:2019-03-15 06:43:21

相关推荐

linux配置vscodec运行环境 Linux 下 VSCode c/c++环境配置

8种机械键盘轴体对比

本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选?

切换中文

安装完成的VSCode是英文的,作为一个英文不好的中国人,我还是喜欢看中文的接口。

点击左侧的

会进入扩展商店

拓展商店中直接搜索Chinese 然后点击Install就行

安装完成后重启应用就会变成中文接口。

安装插件

Code Runner

安装完成后窗口菜单栏下面就会出来一个

当你的显示页面是一个进程源文档(单个文档,不是项目)时,点击这个按钮或者按ctrl+F5就可以直接运行这个进程,方便快捷。

点击齿轮,点击配置,然后把右侧的Run In Terminal勾上,就会在控制面板显示运行结果

c/c++

必装的插件。

C++ Intellisense

C++的只能提示工具

C/C++ Clang Command Adapter

提供静态检测(Lint)

配置环境

主要是连个json文档

launch.json

点击调试,然后选择添加配置。会自动生成lanunch.json文档

这是我的配置,可以直接复制过去

要注意的就是

"program": "${workspaceFolder}/hello.out", //当前目录下编译后的可执行文档"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应该是你生成的执行文档,而build 应该是你的tasks的lable

```json

{

// Use IntelliSense to learn about possible attributes.

// Hover to view descriptions of existing attributes.

// For more information, visit: /fwlink/?linkid=830387

"version": "0.2.0",

"configurations": [

{

"name": "debug cpp", //名称

"type": "cppdbg",

"request": "launch",

"program": "${workspaceFolder}/hello.out", //当前目录下编译后的可执行文档

"args": [],

"stopAtEntry": false,

"cwd": "${workspaceFolder}", //表示当前目录

"environment": [],

"externalConsole": false, // 在vscode自带的终端中运行,不打开外部终端

"MIMode": "gdb", //用gdb来debug

"setupCommands": [

{

"description": "Enable pretty-printing for gdb",

"text": "-enable-pretty-printing",

"ignoreFailures": true

}

],

"preLaunchTask": "build" //执行lanuch之前运行的task

}

]

}

tasks.json

按住ctrl+shift+p

输入tasks,选择configure Task

选择使用模板创建然后选others

就会生成tasks.json文档

仍旧可以直接拷贝

参数应该是自己的,多个文档编译,和在bash中写一样,也可以用makefile1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17{

// See /fwlink/?LinkId=733558

// for the documentation about the tasks.json format

"version": "2.0.0",

"tasks": [

{

"label": "build", // task的名字

"type": "shell",

"command": "g++", //编译命令

"args": [ //编译参数列表

"hello.cpp",

"-o",

"hello.out"

]

}

]

}

c_cpp_properties.json

ctrl+shift+p 输入c/c++:Edit Configurations选择这一项就可以创建一个c_cpp_properties.json文档

不用改动,我也贴出来我的配置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

}

如果有自己的外链库也是添加到这里面。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。