Vscode在linux下配置c/c++环境
(Vscode)Linux远程c/c++环境搭建
Linux端安装基础软件
1、换源
vi /etc/apt/sources.list
//阿里云源
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
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的默认配置只有当前目录,需要将系统依赖导入进去。
在linux系统中输入命令:
gcc -v -E -x c++ -
将最后面的include路径都添加到c_cpp_properties.json文件中,该文件在vscode工作目录下.vscode文件夹中