ubuntu 14.04更新GCC版本

news2024/10/7 20:34:43

按最基本的apt-get install gcc-8,不成功,提示如下。

按网上说的:apt-get update  ,apt-get upgrade 后都无效果。

apt-cache search get 搜索后,发现资源链接里最新的也只有4.8.4所以不行。

需要更新资源链接,镜像地址。

1.替换软件更新源方法:

ubuntu 安装gcc 或g++ 时提示未发现软件包 gcc或g++_无法定位软件包gcc_只是个~小不点的博客-CSDN博客 2. 添加软件源方法

https://wenku.csdn.net/answer/881c213342fe46979aaba123b7ebbcf5     

命令:sudo add-apt-repository ppa:ubuntu-toolchain-r/test来添加源,然后使用 sudo apt-get update命令来更新软件源。最后使用 sudo apt-get install gcc-8来安装。

3.使用update-alternatives指定GCC默认版本

https://blog.csdn.net/Nirvana15/article/details/122317525?spm=1001.2014.3001.5502

4.更新阿里云软件源也没有解决。最后用2中PPA的软件源安装成功。

1.

问题:安装gcc 或g++ 时提示未发现软件包?
1.这时,只需更新apt-get即可,那么apt-get是什么呢?
apt-get,是一条linux命令,适用于deb包管理式的操作系统,主要用于自动从互联网的软件仓库中搜索、安装、升级、卸载软件或操作系统。

输入命令:sudo apt-get update

如果更新时出现卡顿或很慢,是由于我们用的是外网,或者我们电脑的网络过慢

对于前者我的建议是换源
2.什么原因造成的呢?
因为我们安装好ubuntu双系统\单系统后,默认的软件更新源是国外的,
我们可以打开源目录看看:
先切换到目录:
cd /etc/apt
查看/编辑目录:
sudo vi sources.list
我们可以发现:里面的源都是关于cn.archive.ubuntu.com
这个就是国外的软件更新源

3.怎么解决呢?
国外的软件更新源在国内使用速度很慢,需要更换成国内的源,这样才能正常安装和更新软件。

怎么更换呢?
打开终端命令行界面中,先将sources.list文件备份一个,更新源服务器地址就是存在这个文件里面的,所以主要就是对这个文件进行编辑就可以了,也是很简单的。

1.先切换到目录:cd /etc/apt

2.备份源(防止意外或后续需要)
输入:sudo cp sources.list sources.list.old

3.编辑源:sudo vim sources.list

4.将文件中内容全部删除

5.更换源,有一下几种源可以选择,推荐阿里云
(1)、阿里云
 

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

(2)、清华大学

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

(3)、中科大

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

6、复制其中一种粘贴完后,要对照一下,有没有粘贴格式的错误或缺了哪些东西,然后保存退出。最后别忘了更新缓存。
输入:sudo apt-get update
更新缓存需要一点时间,更新完就可以了。

执行sudo apt-get update后续出现的问题,如没出现请忽略:
如输入:sudo apt-get update后出现这些信息
 

W: Unknown Multi-Arch type 'no' for package 'compiz-core'
W: Unknown Multi-Arch type 'no' for package 'compiz-gnome'
W: Unknown Multi-Arch type 'no' for package 'libxapian-dev'
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-min
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-min
W: Unknown Multi-Arch type 'no' for package 'kwin'
W: Unknown Multi-Arch type 'no' for package 'kwin-dev'
W: Unknown Multi-Arch type 'no' for package 'kwin-wayland'
W: Unknown Multi-Arch type 'no' for package 'kwin-x11'
W: Unknown Multi-Arch type 'no' for package 'libkf5sysguard-dev'
W: Ignoring Provides line with DepCompareOp for package php-psr-http-message-implementation
W: Ignoring Provides line with DepCompareOp for package php-psr-log-implementation
W: Ignoring Provides line with DepCompareOp for package php-seclib
W: Ignoring Provides line with DepCompareOp for package php-sabre-http
W: Ignoring Provides line with DepCompareOp for package php-math-biginteger
W: Ignoring Provides line with DepCompareOp for package pypy-cffi
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-min
W: Unknown Multi-Arch type 'no' for package 'compiz-core'
W: Unknown Multi-Arch type 'no' for package 'compiz-gnome'
W: Unknown Multi-Arch type 'no' for package 'libxapian-dev'
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python-cffi-backend-api-min
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package python3-cffi-backend-api-min
W: Unknown Multi-Arch type 'no' for package 'kwin-dev'
W: Unknown Multi-Arch type 'no' for package 'kwin-wayland'
W: Unknown Multi-Arch type 'no' for package 'kwin-x11'
W: Unknown Multi-Arch type 'no' for package 'libkf5sysguard-dev'
W: Ignoring Provides line with DepCompareOp for package pypy-cffi
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-min
W: Unknown Multi-Arch type 'no' for package 'compiz-core'
W: Unknown Multi-Arch type 'no' for package 'compiz-gnome'
W: Ignoring Provides line with DepCompareOp for package xserver-xorg
W: Ignoring Provides line with DepCompareOp for package php-math-biginteger
W: Ignoring Provides line with DepCompareOp for package pypy-cffi
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-min
W: Unknown Multi-Arch type 'no' for package 'compiz-core'
W: Unknown Multi-Arch type 'no' for package 'compiz-gnome'
W: Ignoring Provides line with DepCompareOp for package xserver-xorg
W: Ignoring Provides line with DepCompareOp for package pypy-cffi
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-max
W: Ignoring Provides line with DepCompareOp for package pypy-cffi-backend-api-min

W: 您可能需要运行 apt-get update 来解决这些问题
怎么办呢?

执行如下命令:sudo apt-get install -f apt

再次输入:sudo apt-get update
OK,问题解决

3.选择GCC默认版本

#############切换gcc/g++版本##############
gcc -v
g++ -v
查看系统已有版本
ls /usr/bin/gcc*
ls /usr/bin/g++*
安装
sudo apt install gcc-4.9
sudo apt install g++-4.9
 
# 安装 gcc-7 / g++-7
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update 
sudo apt-get install gcc-7
sudo apt-get install g++-7
 
切换
先将需要的版本添加到 update-alternatives 中
# gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 40 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
 
# g++
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 40 
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 70
若想删除,执行命令:
 
sudo update-alternatives --remove gcc /usr/bin/gcc-4.9
手动配置 update-alternatives
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
 
输入版本编号

1、sudo apt-get remove gcc-*

sudo apt-get remove g++-*  卸载

2、sudo apt-get install gcc-*

sudo apt-get install g++-* 安装

3、 ls /usr/bin/gcc* -l   查询安装的gcc以及默认指向版本

4、修改默认的gcc和g++版本

sudo update-alternatives --remove-all gcc

sudo update-alternatives --remove-all g++


sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-* 40(*指某一版本,40代表优先级)

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-* 40 (*指某一版本,40代表优先级)
 配置默认的gcc和g++

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

5、gcc--version 查询gcc版本

g++--version 查询g++版本
 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1039617.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

uni-app:实现背景渐变效果

效果 代码 单个渐变色 background-image: linear-gradient(to top right, #f00, #00f); 多个渐变色 background-image: linear-gradient(to bottom, #0073ff 0%, #1d6cff 25%, #1e8bff 50%, #41b3ff 100%); /* 多个渐变色 */ <template><view></view> <…

【Vue.js】使用Element搭建首页导航左侧菜单

目录 Mock.js 是什么 有什么好处 安装mockjs ​编辑 引入mockjs mockjs使用 login-mock Bus事物总线 首页导航栏与左侧菜单搭建 结合总线完成组件通讯 Mock.js 是什么 Mock.js是一个用于生成随机数据的模拟数据生成器。它可以帮助开发人员模拟接口请求&#xff0c;生…

轻松几步操作,视频边框背景虚化无压力

在视频剪辑的世界中&#xff0c;许多人都苦于繁琐的操作和复杂的流程。然而&#xff0c;如果你掌握了正确的工具和方法&#xff0c;许多复杂的任务可以变得简单高效。今天&#xff0c;我将分享一个简单实用的视频剪辑技巧&#xff0c;让你轻松完成批量剪辑视频并虚化边框的快速…

常识判断 --- 党史

目录 中共1~3大 例题 国民党 例题 中共4~5大 例题 中共起义~会议 例题 中共六届六中全会&#xff08;1938年9月&#xff09; 中共七大&#xff08;1945年4月&#xff09; 例题 中共七届二中全会 例题 中共8~10大 中共11~12届全会 例题 中共13~14大 …

基于物联网的农村地区智能微电网系统(Simulink)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

Generative AI 新世界 | 扩散模型原理的代码实践之采样篇

在上一期的文章中&#xff0c;探讨了在 Amazon SageMaker Studio 上使用 QLoRA 等量化技术微调 Falcon 40B 大语言模型。而从本期开始&#xff0c;我们将一起尝试在更深的知识维度&#xff0c;继续探究生成式 AI 这一火热的新知识领域。 亚马逊云科技开发者社区为开发者们提供全…

Leetcode 877. 石子游戏

文章目录 题目代码&#xff08;9.23 首刷看解析&#xff09; 题目 Leetcode 877. 石子游戏 代码&#xff08;9.23 首刷看解析&#xff09; 博弈 class Solution { public:bool stoneGame(vector<int>& piles) {int len piles.size();vector<vector<int>…

纷享销客连接型CRM:营销数字化离不开业务指标化

近日&#xff0c;2023金蝶云星空数字化转型巡展&#xff08;嘉兴站&#xff09;在嘉兴圆满举办。 纷享销客浙江分公司代表受邀参加并发表演讲。 纷享销客浙江分公司代表孙石磊 活动现场&#xff0c;纷享销客浙江分公司代表孙石磊带来主题为《连接型CRM赋能企业新增长》的分享。…

Java LinkedList类详解

目录 什么是LinkedList LinkedList的使用 LinkedList的构造 LinkedList的其他常用方法的介绍 LinkedList的遍历 ArrayList和LinkedList的区别 什么是LinkedList LinkList的底层是双向链表结构&#xff0c;由于链表没有将元素存储在连续的空间中&#xff0c;元素存储在单独…

高速USB转4路RS422串口

基于480Mbps 高速USB转8路串口芯片CH344Q&#xff0c;可以为各类主机扩展出4个独立的串口。CH344芯片支持使用操作系统内置的CDC串口驱动&#xff0c;也支持使用厂商提供的VCP串口驱动程序&#xff0c;可支持Windows、Linux、Android、macOS等操作系统。因CDC类协议和类驱动的原…

Java开发需要的网络基础知识,搞清楚计算机网络底层原理

作者&#xff1a;逍遥Sean 简介&#xff1a;一个主修Java的Web网站\游戏服务器后端开发者 主页&#xff1a;https://blog.csdn.net/Ureliable 觉得博主文章不错的话&#xff0c;可以三连支持一下~ 如有需要我的支持&#xff0c;请私信或评论留言&#xff01; 前言 计算机基础是…

企业内部通讯,WorkPlus助您打造高效沟通平台

企业内部通讯是一个组织高效运营的重要组成部分。随着企业规模的扩大和分布式办公的普及&#xff0c;高效的内部沟通变得尤为关键。作为一家领先品牌&#xff0c;WorkPlus为企业提供了一种先进的解决方案&#xff0c;帮助构建高效沟通平台&#xff0c;提升组织内部协作与协同能…

Windows Server 2008 R2安装CVE-2023-35359相关补丁问题及自动进入修复模式无法启动的问题处理

近日微软发布了Windows紧急高危漏洞“Windows权限提升漏洞”&#xff0c;漏洞编号为&#xff1a;CVE-2023-35359&#xff0c;在Windows Server 2008 R2安装过程中出现系列问题&#xff0c;并出现了自动进入修复模式无法启动的问题&#xff0c;本文记录了相关处理过程。 一、Wi…

Win11恢复Win10右键菜单样式(互换)

Windows11正式版桌面右键菜单的折叠显示&#xff0c;本来很多常用的右键功能&#xff0c;反而需要额外多一次点击才能选中。所以很有网友需要将Win11的右键菜单替换成Win10那种直接显示所有命令的方式&#xff0c;以下就是操作方法&#xff1a; 打开命令提示符&#xff0c;以管…

Mysql生产随笔

目录 1. Mysql批量Kill删除processlist 1.1查看进程、拼接、导出、执行 1.2常见错误解决方案 2.关于时区 3.内存占用优化 记录一下生产过程中的一些场景和命令使用方法&#xff0c;不定期进行更新 1. Mysql批量Kill删除processlist 1.1查看进程、拼接、导出、执行 sho…

龙迅LT9611UXC 2PORT MIPICSI/DSI转HDMI(2.0)转换器+音频,内置MCU

龙迅LT9611UXC 1.描述&#xff1a; LT9611UXC是一个高性能的MIPI DSI/CSI到HDMI2.0转换器。MIPI DSI/CSI输入具有可配置的单 端口或双端口&#xff0c;1高速时钟通道和1~4高速数据通道&#xff0c;最大2Gbps/通道&#xff0c;可支持高达16Gbps的总带 宽。LT9611UXC支持突发…

基于Spring Boot的IT技术交流和分享平台的设计与实现

目录 前言 一、技术栈 二、系统功能介绍 三、核心代码 1、登录模块 2、文件上传模块 3、代码封装 前言 我国科学技术的不断发展&#xff0c;计算机的应用日渐成熟&#xff0c;其强大的功能给人们留下深刻的印象&#xff0c;它已经应用到了人类社会的各个层次的领域&#x…

三大bean的实例化方法

1.使用构造方法(常用) 构造方法可以是私有的,因为bean的实例化使用的是反射 但是构造方法不能是有参构造,否则会报错 2.静态工厂(了解-----老方法) class配置的是工厂类名 只配class还不行,不然创建的是工厂对象,需要把工厂里面的方法配置一下,也就是factory-method 3.使用…

leetcode621 任务调度器

题目 给你一个用字符数组 tasks 表示的 CPU 需要执行的任务列表。其中每个字母表示一种不同种类的任务。任务可以以任意顺序执行&#xff0c;并且每个任务都可以在 1 个单位时间内执行完。在任何一个单位时间&#xff0c;CPU 可以完成一个任务&#xff0c;或者处于待命状态。 …

AI时代的中国困境: ChatGPT为什么难以复制

如今&#xff0c;几乎所有中国互联网大厂都公布了自己的“类ChatGPT”解决方案&#xff0c;有些还公布了背后的关于AI技术模型的详情。 其中最高调的是百度&#xff0c;其“文心一言”解决方案号称即将接入数十家内容平台和数以百计的媒体、自媒体。腾讯公布的微信 AI 模型“W…