Ubuntu安装VScode以及安装GCC
Installing GCC on Ubuntu 20.04
$sudo apt-get update
$sudo apt-get install build-essential
$sudo apt-get install manpages-dev
$gcc --version
Ubuntu 20.04 repositories provide GCC version 9.3.0:
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$nano hello.c
// hello.c
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
```
```bash
$gcc hello.c -o hello
$./hello
The program should print:
Hello World!
镜像
- 用
sudo gedit /etc/apt/sources.list
打开,把地址复制进去
镜像地址加速–阿里云
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
- 如何卸载GCC
sudo dpkg -l | grep gcc
- 安装gcc报错信息
rudy@rudy:~/Desktop$ sudo apt install build-essential
[sudo] password for rudy:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: g++ (>= 4:7.2) but it is not going to be installed
Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ wily main
deb-src http://us.archive.ubuntu.com/ubuntu/ wily main
###### Ubuntu Update Repos
deb http://us.archive.ubuntu.com/ubuntu/ wily-security main
deb http://us.archive.ubuntu.com/ubuntu/ wily-updates main
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-security main
deb-src http://us.archive.ubuntu.com/ubuntu/ wily-updates main
- 处理gcc安装报错信息
$sudo gedit /etc/apt/sources.list