如何在Oracle Linux 8.10中安装GCC-Toolset 15?(官方文档显示支持但dnf安装失败)
The issue you're facing happens because GCC-Toolset 15 is delivered as a module in Oracle Linux 8's Application Stream, and the default active module stream for gcc-toolset likely points to version 14 instead of 15. Here's how to fix it:
Step-by-Step Solution
Verify available GCC-Toolset modules (optional sanity check):
First, confirm that the 15 module stream exists in your system's repositories by running:dnf module list gcc-toolsetYou should see an entry like
gcc-toolset:15listed under the Oracle Linux 8 Application Stream repository.Enable the GCC-Toolset 15 module and install the package:
Update your Dockerfile to explicitly enable the 15 module stream before installing the package. This tells DNF to target the correct version:FROM oraclelinux:8.10 RUN dnf module enable -y gcc-toolset:15 && dnf install -y gcc-toolset-15 ENTRYPOINT ["/bin/bash"]The
-yflags skip interactive confirmation, which is critical for non-interactive environments like Docker builds.Rebuild and test your image:
Re-run your Docker build command:docker build -t gcc-docker .This should successfully resolve the
gcc-toolset-15package and complete the installation.
Why This Works
Oracle Linux 8 uses Application Stream modules to ship multiple versions of software without conflicting with the system's default tools. By default, the gcc-toolset module may be set to the 14 stream on Oracle Linux 8.10. Explicitly enabling the :15 stream directs DNF to pull packages from that specific module version, aligning with what's documented in OL-PRODUCT-LIFECYCLE.pdf.
If you need to use GCC-Toolset 15 in a shell session after installation, activate it with:
scl enable gcc-toolset-15 bash
You can also add this activation line to your shell profile for persistent use across sessions.
内容的提问来源于stack exchange,提问作者user31649152

