首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Ubuntu 21.04上安装gcc/g++ 6

在Ubuntu 21.04上安装gcc/g++ 6
EN

Ask Ubuntu用户
提问于 2021-10-20 01:32:44
回答 1查看 2K关注 0票数 0

我正在尝试编译Cuda 10.2,并且可以预见gcc-10将无法编译它。当使用20.04很简单,添加仿生回购,更新,安装,更新-替代。用21.04我什么也做不了。

我尝试了异种和仿生的“主”和“宇宙”回复,这给PUBKEY带来了一个错误。我从ubuntu密钥服务器获得了PUBKEY,并更新了包列表,没有错误。

代码语言:javascript
复制
sudo apt install g++-6

Package g++-6 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'g++-6' has no installation candidate

sources.list ->

代码语言:javascript
复制
deb http://archive.ubuntu.com/ubuntu hirsute restricted main multiverse universe

deb http://archive.ubuntu.com/ubuntu hirsute-updates restricted main multiverse universe

deb http://archive.ubuntu.com/ubuntu hirsute-security restricted main multiverse universe

# gcc-6
deb [allow-insecure=yes] http://dk.archive.ubuntu.com/ubuntu/ bionic main universe
#deb [allow-insecure=yes] http://dk.archive.ubuntu.com/ubuntu/ xenial main universe

有人知道我如何使用Ubuntu21.04实现这个目标吗?我读过的每一篇文章都说要添加仿生或异种回复,更新,安装。到目前为止我还没有运气。

EN

回答 1

Ask Ubuntu用户

发布于 2021-10-21 20:41:20

我抓取了浏览Ubuntu 这里所需的软件包(.deb)。

下面列出了手动安装gcc/g++ 6所需的.deb软件包。按列表顺序安装。这假设您拥有编译所需的大多数工具,并且只需要切换默认的gcc版本。

代码语言:javascript
复制
sudo apt install ./libisl19_0.19-1_amd64.deb
sudo apt install ./gcc-6-base_6.4.0-17ubuntu1_amd64.deb
sudo apt install ./cpp-6_6.4.0-17ubuntu1_amd64.deb

# you can grab this next package from 21.04 repos, it handles a lot of the dependancies.
sudo apt install libgcc-6-dev

# Finally
sudo apt install ./gcc-6_6.4.0-17ubuntu1_amd64.deb

# GCC-6 is now installed, you can test by gcc-6 -v
baudneo@ZMES-test:~$ gcc-6 -v
gcc version 6.4.0 20180424 (Ubuntu 6.4.0-17ubuntu1)

# Now for G++ 6
sudo apt install ./libstdc++-6-dev_6.4.0-17ubuntu1_amd64.deb
sudo apt install ./g++-6_6.4.0-17ubuntu1_amd64.deb

# G++-6 is now installed! test by g++-6 -v
baudneo@ZMES-test:~$ g++-6 -v
gcc version 6.4.0 20180424 (Ubuntu 6.4.0-17ubuntu1)

# Now it is time to configure the system to use GCC G++ 6
# This assumes you do not have other versions of gcc and g++ installed for other projects

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 100
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 100
sudo update-alternatives --set c++ /usr/bin/g++
# When you want to revert these back to default gcc-10
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 100
sudo update-alternatives --set c++ /usr/bin/g++
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1370373

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档