在 CentOS 上下载 GCC 源码 常见有几种方式,按推荐程度给你说明。
访问官网:
https://gcc.gnu.org/
cd /usr/local/src
wget https://ftp.gnu.org/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz
tar -xf gcc-13.2.0.tar.xz
cd gcc-13.2.0
✅ 优点
如果国外网络慢,可以用 清华大学镜像站:
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-13.2.0/gcc-13.2.0.tar.xz
git clone https://gcc.gnu.org/git/gcc.git
或者指定分支:
git clone -b releases/gcc-13 https://gcc.gnu.org/git/gcc.git gcc-13
✅ 适合研究 GCC 源码
❌ 体积大、编译慢
yum install -y yum-utils
yumdownloader --source gcc
或:
dnf download --source gcc
解压:
rpm2cpio gcc*.src.rpm | cpio -idmv
⚠️ 注意:
如果你是要 编译 GCC,还需要下载依赖:
cd gcc-13.2.0
./contrib/download_prerequisites
它会自动下载:
| 目的 | 推荐方式 |
|---|---|
| 升级 GCC | ✅ GNU 官方或清华镜像 |
| 研究源码 | ✅ Git |
| 系统调试 | ✅ CentOS 源码 RPM |
如果你愿意,我可以帮你:
你是 CentOS 几? 想 升级还是研究源码?