vscode 远程 开发 centos7 c语言
本地vscode,搭建centos7的c语言开发环境
-
远程主机一台或本地虚拟主机一台;本地电脑需要安装vscode的软件,vscode下载链接;vscode需要安装remote-ssh插件
*vscode的debug参考文档 -
远程主机
- 安装gcc
yum install -y gcc gdb
- 查看gcc是否安装成功,
gcc -v
- 安装gcc
-
vscode用远程开发工具链接到centos
- 打开插件市场,搜索c/c++
- 重启vscode
#创建一个文件夹
mkdir demo
touch main.c
# include <stdio.h>
int main(void) {
printf("hello, world\n");
return 0;
}
- vscode选择顶部菜单栏依次选择 Terminal > Configure Default Build Task,并在弹出框里选择 C/C++: gcc build active file。
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc 生成活动文件",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/build/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "编译器: /usr/bin/gcc"
},
]
}
- vscode创建一个launch.json,选择Add Debug Configuration,选择g++ build and debug active file.
{
// 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "C/C++: g++ build active file"
},
]
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】
2021-07-08 DockerFile