AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 767757
Accepted
eyoung100
eyoung100
Asked: 2024-01-26 06:57:07 +0800 CST2024-01-26 06:57:07 +0800 CST 2024-01-26 06:57:07 +0800 CST

我正在使用随编译器 $Y 一起提供的发行版 $X,但我需要编译器版本 $Z

  • 772

问题

这个问题以及包含解决该问题的各种方法的答案几乎每天都会在我们的交流中多次出现。如果搜索结果将您带到这里欢迎!如果我在链接到您的问题中留下的评论,您可以放心地假设您的问题可以添加到下面的列表中,因为它属于同一类别:

  • gcc降级后glib和gcc之间的分歧
  • 如何在 Fedora 39 上降级到特定的 gcc 版本?
  • 如何在 arch linux 中安装一些 gcc 编译器?
  • Debian Bullseye:安装 gcc-11.4.0 和依赖项

这些只是[gcc]搜索词降级所标记的众多问题中的四个。那些知识渊博、能够先来交流的读者/用户几乎总是会问我怎样才能……”那些尝试过失败的不幸读者几乎总是会说“它坏了”,或者“我想我坏了一些东西”。这个问题和答案,我将尝试解释为什么混合编译器会破坏所有Linux,并且在答案中我将提供我所知道的解决问题的最简单方法,这不会导致损坏,但会花费一些开销设置的时间和空间。由于这将是社区贡献的问答,如果您喜欢我的方法,我恳请您投票。

问题解释

TLDR:跳至为什么降级编译器会导致问题?

我在各种答案中使用了下面的图片两到三次,我觉得它为我们所有人提供了一个很好的起点。我意识到它很大,因此,如果您愿意,我敦促读者在单独的选项卡中打开它并进行缩放等。

Linux 发行版的时间表

在该列表中找到您的发行版,然后继续阅读。您会注意到您的发行版有一个父发行版。好吧,好吧,我知道使用父发行版(时间轴最左边的发行版)的读者会问:

我正在使用最左边的一个,那么它的父母在哪里?

现在我们进入这个问题的核心。例如,让我们填写$X我$Y的标题(耐心的读者,$Z即将出现)

  • $X = Fedora 39
  • $Y = 13.2.1-6.fc39

定义

  • Distribution (Quoting Wikipedia):

A Linux distribution (often abbreviated as distro) is an operating system made from a software collection that includes the Linux kernel and often a package management system.

  • Package Management System (Quoting Again):

A package manager or package-management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner

Knowing these two items helps us answer the Parent Distribution question, but unfortunately with another question: How Do the distribution maintainers create a distribution?

The Answer: All linux software minus the kernel is stored at and can be obtained from the GNU Software FTP Site in source code archives. All Linux Kernels are available for download in source code archives at The Linux Kernel Archives. In short, all Distributions begin from the same source code, including the parent distributions

Why Does Downgrading Compilers Cause Issues?

From the definition earlier, a distribution is a group or set of related software. This relation can be seen in your distribution's repository (or whatever else your distribution has chosen to name it).

At the time a new version (in our Example $X = Fedora 39) is made available the repository for that version is locked, specifically version locked, meaning that every package in that repository is now frozen in time. Once frozen it isn't altered. It can only live as long as the version is supported or die when the version is upgraded.

The tools required to build GCC are also in the now frozen repository. If a user attempts to upgrade or downgrade the GCC that was shipped in the frozen repository, the version locking would be broken if you were to succeed. To prevent the breakage from happening, your OS'es Package Manager prevents this.

Read my answer to find out how I overcame $Z

package-management
  • 2 2 个回答
  • 105 Views

2 个回答

  • Voted
  1. Stephen Kitt
    2024-01-26T13:44:19+08:002024-01-26T13:44:19+08:00

    A less heavyweight solution is to use containers. Install Docker or Podman, and follow the recipe in eyoung100’s answer to identify the distribution release you’re after, or look it up on Repology.

    Using the same Fedora 36 example, run a container:

    podman run -it fedora:36
    

    您可以添加-v选项以使系统上的目录在容器内可用:

    podman run -it -v ~/myproject:/myproject:z fedora:36
    

    (仅:z当您使用 SELinux 时才添加)。

    在容器中,安装gcc您需要的任何其他工具,构建您的项目(在 中/myproject),然后您将在共享的目录中找到您的文件。

    • 2
  2. Best Answer
    eyoung100
    2024-01-26T06:57:07+08:002024-01-26T06:57:07+08:00

    My Solution

    First off, I guess I would be considered a purist in that if a package isn't in your repository, or can't be added from a third party repository, you shouldn't attempt to compile it from scratch or "force it to work" because doing so short-circuits your package manager. With that in mind, I present a rock-solid solution


    Virtualization Is Our Friend

    We need some tools and a bit of Hard Drive Space for this approach. I'll leave making space available to you but aside from that follow these steps:

    1. Install VirtualBox with your package manager
    2. Install Vagrant with your package manager

    Note: Vagrant will work with Hyper-V and docker out of the box I believe (see Stephen Kitt's answer for help with docker), but I chose VirtualBox because that's what I learned first, and if needed I can install a Desktop in the VM to configure the VM further.

    With our Virtualization Helpers installed we can continue. I'm continuing by:

    1. Gathering Requirements - I came up as a web programmer, so let's gather requirements from our customer. For our purposes, I'm going to fill in $Z now. Using Example question 2 from the Issue heading above we have the following values:
      • $X = Fedora
      • $Y = 13.2.1-6.fc39
      • $Z = 12.x.x
    2. Always use the following sentence as the Search term in your favorite engine: Which release of $X contained GCC $Z

    So using our example: Which release of Fedora contained GCC 12. Now Quoting Google:

    Update the Fedora 36 GNU Toolchain to gcc 12 and glibc 2.35. The gcc 12 is currently under development and will be included in Fedora 36 upon release. Feb 16, 2022

    1. Let's check to see if the above release - 36 - is still supported. In our search engine:
      $X release history

    Which would equate to Fedora release history in our example, which gives us Fedora Linux release history. Well, what do we do now? It looks like Fedora 36 is no longer supported. We added Vagrant for this very reason. If we visit The Vagrant Cloud, we can search for Fedora 36, which yields these results, and using a Vagrantfile, we can customize a full VM version and develop our application or website using the VM while saving our project files on our host system.

    Reason Why I Chose This Approach

    Using virtualization separates your development environment from the system you use day-to-day, and keeps you from making an irreparable mistake. I realize it will cost a bit of extra setup time, but Vagrant only needs to be installed once. A vagrantfile only needs to be created each time your project requirements change. The small learning curve for Vagrant and the Virtualization is worth the tradeoff of reinstalling an OS if a mistake is made trying to figure out how to install multiple compilers.

    • 1

相关问题

  • 如何在 Kali Linux 中安装特定版本的 GCC?

  • 是否可以构建同时支持 RPM 和 .deb 软件包的 Linux 发行版?

  • dh_usrlocal: ... 不是目录

  • 了解 apt 列表输出

  • 使用 shell 脚本安装 ncdf4 R 包

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve