---
title: "linux下安装gcc"
author: "helpbs"
date: "2007-12-29T09:37:00Z"
tags: []
slug: "linux-gcc"
draft: false
lastmod: "2012-04-20T18:30:28Z"
id: 1492117
url: "https://helpbs.iteye.com/blog/1492117"
---

系统

Red Hat Enterprise Linux AS release 4 (Nahant Update 1)

安装 gcc之前google了一下，发现这是个麻烦事，心里也做好了准备，花费了一下午终于搞定，

事先确定要安装符合rhel4的rpm,由此找到下面这个网址：

[http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/)

里面很全，基本涵盖了安装gcc所需的所有其他rpm

1）安装gcc

wget [http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/gcc-3.4.6-9.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/gcc-3.4.6-9.i386.rpm)

rpm -ivh gcc-3.3.2-6.i386.rpm

warning: gcc-3.4.6-9.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821

error: Failed dependencies:

binutils &gt;= 2.15.92.0.2-18 is needed by gcc-3.4.6-9.i386

cpp = 3.4.6-9 is needed by gcc-3.4.6-9.i386

glibc-devel &gt;= 2.2.90-12 is needed by gcc-3.4.6-9.i386

libgcc &gt;= 3.4.6-9 is needed by gcc-3.4.6-9.i386

Suggested resolutions:

glibc-devel-2.3.4-2.9.i386.rpm

失败

根据错误信息--〉1-1，1-2，1-3，1-4

1-1)更新binutils

wget[http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/binutils-2.15.92.0.2-24.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/binutils-2.15.92.0.2-24.i386.rpm)

rpm -Uvh binutils-2.15.92.0.2-24.i386.rpm

1-2）更新cpp

wget [http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/cpp-3.4.6-9.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/cpp-3.4.6-9.i386.rpm)

rpm -Uvh cpp-3.4.6-9.i386.rpm

1-3)更新libgcc

wget [http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/libgcc-3.4.6-9.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/libgcc-3.4.6-9.i386.rpm)

rpm -Uvh libgcc-3.4.6-9.i386.rpm

1-4)更新glibc-devel

wget [http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-devel-2.3.4-2.39.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-devel-2.3.4-2.39.i386.rpm)

rpm -ivh glibc-devel-2.3.4-2.39.i386.rpm

warning: glibc-devel-2.3.4-2.39.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821

error: Failed dependencies:

glibc = 2.3.4-2.39 is needed by glibc-devel-2.3.4-2.39.i386

glibc-headers is needed by glibc-devel-2.3.4-2.39.i386

glibc-headers = 2.3.4-2.39 is needed by glibc-devel-2.3.4-2.39.i386

Suggested resolutions:

glibc-headers-2.3.4-2.9.i386.rpm

根据错误信息---〉1-4-1，1-4-2

1-4-1）更新glibc

wget[http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-2.3.4-2.39.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-2.3.4-2.39.i386.rpm)

warning: glibc-2.3.4-2.39.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821

error: Failed dependencies:

glibc-common = 2.3.4-2.39 is needed by glibc-2.3.4-2.39.i386

根据错误信息--〉1-4-1-1

1-4-1-1)

wget[http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-common-2.3.4-2.39.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-common-2.3.4-2.39.i386.rpm)

rpm -Uvh glibc-common-2.3.4-2.39.i386.rpm

warning: glibc-common-2.3.4-2.39.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821

error: Failed dependencies:

glibc-common = 2.3.4-2.9 is needed by (installed) glibc-2.3.4-2.9.i686

又出错，强行更新，反正这个也不会用，以及依赖它的rpm也要跟新

rpm -Uvh glibc-common-2.3.4-2.39.i386.rpm --nodeps--force

返回到1-4-1）

rpm -Uvh glibc-2.3.4-2.39.i386.rpm

1-4-2）安装glibc-headers

wget [http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-headers-2.3.4-2.39.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-headers-2.3.4-2.39.i386.rpm)

rpm -ivh glibc-headers-2.3.4-2.39.i386.rpm

warning: glibc-headers-2.3.4-2.39.i386.rpm: V3 DSA signature: NOKEY, key ID 443e1821

error: Failed dependencies:

kernel-headers is needed by glibc-headers-2.3.4-2.39.i386

kernel-headers &gt;= 2.2.1 is needed by glibc-headers-2.3.4-2.39.i386

Suggested resolutions:

glibc-kernheaders-2.4-9.1.87.i386.rpm

根据出错信息---〉1-4-2-1

1-4-2-1）安装glibc-kernheaders

wget[http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-kernheaders-2.4-9.1.100.EL.i386.rpm](http://mirrors.jtlnet.com/centos/4/apt/i386/RPMS.os/glibc-kernheaders-2.4-9.1.100.EL.i386.rpm)

rpm -ivh glibc-kernheaders-2.4-9.1.100.EL.i386.rpm

返回1-4-2 )

rpm -ivh glibc-headers-2.3.4-2.39.i386.rpm

返回1-4)

rpm -ivh glibc-devel-2.3.4-2.39.i386.rpm

返回1）

rpm -ivh gcc-3.4.6-9.i386.rpm

安装完成，gcc -v

显示信息

gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)