美文网首页
gcc安装时,无C compile错误处理

gcc安装时,无C compile错误处理

作者: brightranger | 来源:发表于2017-03-22 19:27 被阅读43次

在全新的linux系统中,有时系统包中没有默认的gcc,所以需要全新安装gcc。然而下载的gcc原码包,在安装的时候需要先有c compiler软件。下面是网上搜的可行解决办法:


  1. 下载安装原CentOS5-Base-163.repo
    <pre>[root@localhost~]# wget http://mirrors.163.com/.help/CentOS5-Base-163.repo
    --2015-10-09 14:33:10-- http://mirrors.163.com/.help/CentOS5-Base-163.repo
    Resolving mirrors.163.com... 123.58.173.186,123.58.173.185
    Connecting to mirrors.163.com|123.58.173.186|:80...connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 2341 (2.3K) [application/octet-stream]
    Saving to: CentOS5-Base-163.repo' 100%2,341 --.-K/s in 0s 2015-10-09 14:33:22 (108 MB/s) -CentOS5-Base-163.repo' saved [2341/2341]
    </pre>

  2. 修改repo文件(根据红帽版本)
    <pre>[root@localhost~]# mv CentOS5-Base-163.repo /etc/yum.repos.d/</pre>*** 把$releasever替换成5 (红帽6版本以上的改为6)
    <pre>[root@localhost yum.repos.d]# sed -i 's#$releasever#5#g' ./CentOS5-Base-163.repo</pre>

  3. 清除原有缓存
    <pre>[root@localhost yum.repos.d]# yum clean all
    Loaded plugins: katello, product-id, security, subscription-manager
    Updating certificate-based repositories.
    Unable to read consumer identity
    Cleaning up Everything</pre>

  4. 获取yum列表
    <pre>[root@localhost yum.repos.d]# yum makecache
    Loaded plugins: katello, product-id, security, subscription-manager
    Updating certificate-based repositories.
    Unable to read consumer identity
    addons | 1.9 kB 00:00
    addons/filelists_db | 570 B 00:00
    addons/other_db | 554 B 00:00
    addons/primary_db | 1.1 kB 00:00
    base | 1.1 kB 00:00
    base/filelists | 3.7 MB 00:11
    base/other | 14 MB 01:04
    base/group | 1.1 MB 00:03
    base/primary | 1.3 MB 00:06
    epel | 3.6 kB 00:00
    epel/filelists_db | 4.1 MB 00:16
    epel/updateinfo | 510 kB 00:02
    epel/other_db | 1.6 MB 00:05
    epel/primary_db | 2.9 MB 00:14
    extras | 2.1 kB 00:00
    extras/filelists_db | 224 kB 00:00
    extras/other_db | 442 kB 00:01
    extras/group | 9.7 kB 00:00
    extras/primary_db | 173 kB 00:00
    updates | 1.9 kB 00:00
    updates/filelists_db | 2.1 MB 00:09
    updates/other_db | 11 MB 00:29
    updates/primary_db | 531 kB 00:00
    base 3667/3667
    base 3667/3667
    base 3667/3667
    Metadata Cache Created</pre>

  5. 搜索安装
    <pre>[root@localhost ~]# yum search gcc |grep --color '^gcc'
    gcc.x86_64 : Various compilers (C, C++, Objective-C, Java, ...)
    gcc-c++.x86_64 : C++ support for GCC
    gcc-gfortran.x86_64 : Fortran 95 support
    gcc-gnat.x86_64 : Ada 95 support for GCC
    gcc-java.x86_64 : Java support for GCC
    gcc-objc++.x86_64 : Objective-C++ support for GCC
    gcc-objc.x86_64 : Objective-C support for GCC
    gcc44.x86_64 : GNU Compiler Collection version 4.4
    gcc44-c++.x86_64 : C++ support for GCC version 4.4
    gcc44-gfortran.x86_64 : Fortran support for GCC 4.4</pre>

  6. 安装gcc
    <pre>[root@localhost yum.repos.d]# yum -y install gcc</pre>
    至此gcc安装完成。

  7. 注意
    安装pcre-8.39 执行./configure的时候出现错误
    <pre>configure: error: You need a C++ compiler for C++ support</pre>解决办法:
    <pre>yum install -y gcc gcc-c++</pre>

相关文章

网友评论

      本文标题:gcc安装时,无C compile错误处理

      本文链接:https://www.haomeiwen.com/subject/xmqanttx.html