Vscode在linux下配置c/c++环境

(Vscode)Linux远程c/c++环境搭建

Linux端安装基础软件

1、换源

vi /etc/apt/sources.list

//阿里云源 18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

//20.04
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

1、安装ssh

sudo apt-get install openssh-server

2、安装gcc,g++

sudo apt-get install gcc g++

3、安装gdb

sudo apt-get install gdb

4、安装cmake

sudo apt-get install cmake

5、安装open_vm_tools
Vmware Tools工具官方已经不建议。更提倡开源的open-vm-tools,所以我安装了这个:

sudo apt install open-vm-tools

#如果要实现文件夹共享,需要安装 open-vm-tools-dkms
sudo apt install open-vm-tools-dkms

#桌面环境还需要安装 open-vm-tools-desktop 以支持双向拖放文件
sudo apt install open-vm-tools-desktop

Vscode安装插件并配置免密登录

1、安装Remote -ssh插件

2、配置免密登录

先在window下生成公钥:

ssh-keygen -t rsa

再在linux下生成公钥

ssh-keygen -t rsa

在linux生成公钥的目录下,创建authorized_keys文件,并写入windows下生成的公钥

Vscode在Linux下导入头文件警告

这是因为在配置中没有指定依赖路径导致的,在c_cpp_properties.json文件中includePath的默认配置只有当前目录,需要将系统依赖导入进去。
编辑~/.vscode/c_cpp_properties.json
(ctrl + shift + p,键入C/Cpp : Edit Configurations,这样就打开了配置文件), 在includePath字段添加头文件的路径即可

在linux系统中输入命令:

gcc -v -E -x c++ -

将最后面的include路径都添加到c_cpp_properties.json文件中,该文件在vscode工作目录下.vscode文件夹中

原文链接: https://www.cnblogs.com/kusola9808/p/16000971.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Vscode在linux下配置c/c++环境

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/188171

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月12日 下午2:04
下一篇 2023年2月12日 下午2:05

相关推荐