• Ubuntu 12.04 64bit 安装编译GCC 4.1.2 绝对原创


    1. 下载并解压源代码:
    wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
    tar jxvf gcc-4.1.2.tar.bz2

    2. 安装依赖库及软件:
    sudo apt-get install libc6-dev libgmp-dev libmpfr-dev texinfo (这一步能够省去)

    3. 编译gcc:
    cd gcc-4.1.2
    mkdir build
    cd build
    ../configure --prefix=/opt/gcc-4.1.2 --program-suffix=-4.1 --libexecdir=/opt/gcc-4.1.2/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --enable-languages=c,c++

    make bootstrap
    然后是漫长的等待。。

    4. 安装gcc:
    make install
    cd /opt/gcc-4.1.2/bin
    ls -al
    看到i686-pc-linux-gnu-gcc-4.1.2等文件就说明安装完毕啦。

    5. 切换gcc 4.1.2:
    我一般喜欢在主目录下建立一个bin目录,而bin目录默认就在PATH中。然后在bin目录下链接gcc-4.1来切换gcc的不同版本号。


    cd ~
    mkdir bin
    ln -s /opt/gcc-4.1.2/bin/gcc-4.1 gcc
    ln -s /opt/gcc-4.1.2/bin/g++-4.1 g++
    ln -s /opt/gcc-4.1.2/bin/cpp-4.1 cpp
    ln -s /opt/gcc-4.1.2/bin/gcov-4.1 gcov
    ln -s gcc cc
    ln -s g++ c++
    如今又一次登录,输入gcc -v 或 cc -v就能够显示gcc已经变成4.1.2版本号啦。

    注意编译时遇到的问题小结:

    (1)makeinfo的问题

    # ./configure 

    接着就出现错误

    WARNING: `makeinfo' is missing on your system. You should only need it if
    you modified a `.texi' or `.texinfo' file, or any other file
    indirectly affecting the aspect of the manual. The spurious
    call might also be the consequence of using a buggy `make' (AIX,
    DU, IRIX). You might want to install the `Texinfo' package or
    the `GNU make' package. Grab either from any GNU archive site.
    make[3]: *** [fastjar.info] 错误 1
    make[3]:正在离开文件夹 `/home/ssm/gcc-obj/fastjar'
    make[2]: *** [all] 错误 2
    make[2]:正在离开文件夹 `/home/ssm/gcc-obj/fastjar'
    make[1]: *** [all-fastjar] 错误 2
    make[1]:正在离开文件夹 `/home/ssm/gcc-obj'
    make: *** [all] 错误 2


    (主要原因是GCC的版本号过高)

    1:全英文的这部分说的是你的系统中缺少对应版本号的makeinfo软件。

    由于gcc4.1以上的版本号须要makeinfo的版本号为4.2或更高。
    所以输入命令行:
    makeinfo –version           想查看makeinfo的版本号。结果得到了下面信息:
    The program ‘makeinfo’ is currently not installed. You can install it by typing:
    yum install texinfo
    依照提示输入命令。问题得到解决。

    2:本机使用的Texinfo是4.11版本号。

    出现此错误的原因也在于configure文件中texinfo对该版本号不支持。能够在解压gcc4.1.1目录中的configure文件中找到

    下面语句

    # For an installed makeinfo, we require it to be from texinfo 4.2 or
    # higher, else we use the “missing” dummy.
    if ${MAKEINFO} –version
    | egrep ‘texinfo[^0-9]*([1-3][0-9]|4.[2-9]|[5-9])’ >/dev/null 2>&1; then
    :
    else
    MAKEINFO=”$MISSING makeinfo”
    fi
    ;;

    当中4.[2-9]|[5-9]表示的是支持4.2-4.9之间的几个版本号,所以须要自己加入4.[1-9][0-9]*,以支持4.11版本号。即把’texinfo[^0-9]*([1-3][0-9]|4.[2-9]|[5-9])’编辑成’texinfo[^0-9]*([1-3][0-9]|4.[2-9]|4.[1-9][0-9]*|[5-9])’后保存。编译通过。

    (2)/usr/bin/ld: cannot find crti.o: No such file or directory

    假设出现该
    /usr/bin/ld: cannot find crti.o: No such file or directory
    提示错误。说明是64位机子造成的。
    解决64位的:
    sudo ln -/usr/lib/x86_64-linux-gnu /usr/lib64

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    python基础---内置类型
    python基础---内置常量
    python基础---内置函数
    数据增强---CutMix
    数据增强---Mixup
    机器学习笔记---评估方法
    深度学习笔记-上溢和下溢
    线性代数笔记-子空间
    tensorflow2学习笔记---模块、层和模型
    tensorflow2学习笔记---Graph和tf.function
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4844808.html
Copyright © 2020-2023  润新知