如何安装GMP,MPFR,MPC,ELF,无需共享库? [英] How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries?

查看:188
本文介绍了如何安装GMP,MPFR,MPC,ELF,无需共享库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用正确版本的依赖关系,使用当前版本,

逐块安装GCC(GNU编译器集合),而不是使用包管理器(如yum,rpm,apt, dpkg),而不是使用共享库?



典型的开发人员可能希望以典型的方式安装GCC,使用您的软件包管理器(yum,rpm,apt,dpkg,port ,brew等)或按照这里的说明操作( http://gcc.gnu.org/wiki/InstallingGCC



我的问题是如何在没有共享库的情况下逐个安装GCC。




  • 我想要一个完全独立的GCC,它可以在不使用任何共享库的情况下在我的系统中移动,也不需要创建任何共享库。
  • 这就是GCC调用困难的方式,不推荐给典型的用户。



GCC取决于:


  • GMP:GNU Multiple Precis离散算术库

  • MPFR:GNU多精度浮点舍入库

  • MPC:GNU多精度C库

  • ELF:可执行和可链接的格式库

  • PPL:Parma多面体库(可选,用于内存优化)

    解决方案

    简单的方法



    如果你是一个典型的开发人员,你可以安装简单的方法,请使用 http://gcc.gnu.org/wiki/InstallingGCC 或您的系统包中的说明例如:

     为Debian,Ubuntu等安装gcc#
    yum install gcc#for RedHat, CentOS等
    brew安装gcc#for Mac OS X



    The Hard Way h2>

    GCC说这里的答案是困难的方式,因为它构建了一块一块地构建,并且不使用共享库。

    GCC基础设施



    获取GCC基础架构:

      ftp://gcc.gnu.org/pub/gcc/infrastructure/ 

    将下载文件放在临时目录中(您可以使用任何您想要的目录)。 $ b

      / opt / downloads 

    在与下载目录及其子目录不同的临时目录中构建基础结构:

      / tmp / gcc 

    使用像这样的静态库配置基础架构:

      ./ configure --disable-shared --enable-static --prefix = / tmp / gcc 

    --disable-shared标志可能值得仔细观察取决于你的需求。我使用--disable-shared,因为我只构建静态代码,并且我想确保不会构建任何共享代码。我的需求是将驱动器的结果轻松移动到我的驱动器中,因此我需要所有静态代码,而且我不需要任何共享代码。如果您更喜欢共享代码,请忽略--disable-shared标志。

    版本



    当您在此答案中运行任何命令时,请务必更新要使用的命令当前的GCC版本号符合您的需求。这个答案中的命令是针对GCC 4.6.2的。



    请注意,GCC文档中提到:虽然任何新版本的必需工具通常都有效,更严格的新版本可能在某些情况下有效,但使用记录的确切版本更安全。

    GMP



    GMP是GNU多精度算术库。

      wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2 
    bunzip2 gmp-4.3.2 .tar.bz2
    tar xvf gmp-4.3.2.tar
    cd gmp-4.3.2
    ./configure --disable-shared --enable-static --prefix = / tmp / gcc
    make&&检查&& make install



    MPFR



    MPFR是GNU多精度浮点舍入库。这取决于GMP。

      wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4。 2.tar.bz2 
    bunzip2 mpfr-2.4.2.tar.bz2
    tar xvf mpfr-2.4.2.tar
    cd mpfr-2.4.2
    ./configure - -disable-shared --enable-static --prefix = / tmp / gcc --with-gmp = / tmp / gcc
    make&&检查&& make install



    MPC



    MPC是GNU多精度C库。它取决于GMP和MPFR。

      wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc- 0.8.1.tar.gz 
    tar zxvf mpc-0.8.1.tar.gz
    cd mpc-0.8.1
    ./configure --disable-shared --enable-static - -prefix = / tmp / gcc --with-gmp = / tmp / gcc --with-mpfr = / tmp / gcc
    make&&检查&& make install



    ELF



    ELF代表可执行和可链接的格式。这个库提供了与架构无关的大小和endian支持。

      wget http://www.mr511.de/software/libelf- 0.8.13.tar.gz 
    tar zxvf libelf-0.8.13.tar.gz
    cd libelf-0.8.13
    ./configure --disable-shared --enable-static - -prefix = / tmp / gcc
    make&&检查&& make install



    GCC



    GCC是GNU编译器集合。它取决于GMP,MPFR,MPC和ELF。

      wget http://www.netgull.com/gcc/releases /gcc-4.6.2/gcc-4.6.2.tar.gz 
    tar zxvf gcc-4.6.2.tar.gz


    相同的挂载点上的暂存目录中构建gcc。 (在/ tmp中构建它将触发交叉编译主机问题)

      mkdir -p /opt/downloads/gcc-4.6.2 -scratch 
    cd /opt/downloads/gcc-4.6.2-scratch

    配置命令及其标志必须全部在一个命令行上(这篇文章仅在网页宽度方面显示它们分开行)。注意:我们使用完整路径进行配置,不要设置库路径环境变量。我们选择禁用引导并禁用共享库,因为我们不希望它们(典型用户可能同时需要这两者),并且使用posix线程和由于我们需要而默认的标志(典型用户可能想要使用其他线程或跳过默认标志)。 YMMV并阅读这里的标志

      /opt/downloads/gcc-4.6.2/configure 
    --disable-shared
    --disable-bootstrap
    --disable- libstdcxx -pch
    --enable-languages = all
    --enable-libgomp
    --enable -lto
    --enable-threads = posix
    --enable -tls
    --with-gmp = / tmp / gcc
    --with-mpfr = / tmp / gcc
    --with-mpc = / tmp / gcc
    - with-libelf = / tmp / gcc
    --with-fpmath = sse
    make&& make install

    此页面非常适合GCC安装信息,如何构建它,各种标志等等:



    http:// www.acsu.buffalo.edu/~charngda/cc_build.html

    更新



    ppl库可用于内存优化:请参阅bugseng.com/products/ppl/Download(感谢Paul的评论)



    您可以运行./contrib/download_prerequisites gcc源码目录。 (感谢reddit上的N7P)


    How do I install GCC (the GNU Compiler Collection) piece by piece, using the current version,
    using the correct versions of dependencies, not using a package manager (like yum, rpm, apt, dpkg), and not using shared libraries?

    Typical developers will likely want to install GCC the typical way, use your package manager (yum, rpm, apt, dpkg, port, brew, etc.) or follow the instructions here (http://gcc.gnu.org/wiki/InstallingGCC).

    My question is how to install GCC piece by piece, without shared libraries.

    • I want a fully-independent GCC that can be moved around my system without using any shared libraries, and without creating any shared libraries.
    • This is what GCC calls "the difficult way" and it is not recommended for typical users.

    GCC depends on:

    • GMP: GNU Multiple Precision Arithmetic Library
    • MPFR: GNU Multiple-precision floating-point rounding library
    • MPC: GNU Multiple-precision C library
    • ELF: Executable and Linkable Format library
    • PPL: Parma Polyhedra Library (optional, for memory optimizations)

    解决方案

    The Easy Way

    If you're a typical developer, you can install the easy way, using instructions at http://gcc.gnu.org/wiki/InstallingGCC or your system package manager such as:

    apt  install gcc  # for Debian, Ubuntu, etc.
    yum  install gcc  # for RedHat, CentOS, etc.
    brew install gcc  # for Mac OS X
    

    The Hard Way

    GCC says the answer here is "the hard way" because it builds everything piece by piece, and does not use shared libraries.

    GCC infrastructure

    Get the GCC infrastructure:

    ftp://gcc.gnu.org/pub/gcc/infrastructure/
    

    Put downloads in a temp directory (you can use whatever directory you want).

    /opt/downloads
    

    Build the infrastructure in a temp directory that is different than the downloads directory or its subdirectories:

    /tmp/gcc
    

    Configure the infrastructure using static libraries like this:

    ./configure --disable-shared --enable-static --prefix=/tmp/gcc
    

    The --disable-shared flag may be worth a closer look depending on your needs. I use --disable-shared because I am building static code only, and I want to make sure that I don't build any shared code. My need is to move the resulting GCC around my drives easily, so I want all static code, and I do not want any shared code. If you prefer shared code, omit the --disable-shared flag.

    Versions

    When you run any of the commands in this answer, be sure to update the commands to use the current GCC version number that matches your needs. The commands in this answer are for GCC 4.6.2.

    Note that the GCC documentation says: "While any sufficiently new version of required tools usually work, library requirements are generally stricter. Newer versions may work in some cases, but it's safer to use the exact versions documented."

    GMP

    GMP is the GNU Multiple Precision Arithmetic Library.

    wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
    bunzip2 gmp-4.3.2.tar.bz2
    tar xvf gmp-4.3.2.tar
    cd gmp-4.3.2
    ./configure --disable-shared --enable-static --prefix=/tmp/gcc
    make && make check && make install
    

    MPFR

    MPFR is the GNU Multiple-precision floating-point rounding library. It depends on GMP.

    wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
    bunzip2 mpfr-2.4.2.tar.bz2
    tar xvf mpfr-2.4.2.tar
    cd mpfr-2.4.2
    ./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc
    make && make check && make install
    

    MPC

    MPC is the GNU Multiple-precision C library. It depends on GMP and MPFR.

    wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
    tar zxvf mpc-0.8.1.tar.gz
    cd mpc-0.8.1
    ./configure --disable-shared --enable-static --prefix=/tmp/gcc --with-gmp=/tmp/gcc --with-mpfr=/tmp/gcc
    make && make check && make install
    

    ELF

    ELF stands for Executable and Linkable Format. This library provides architecture-independent size and endian support.

    wget http://www.mr511.de/software/libelf-0.8.13.tar.gz
    tar zxvf libelf-0.8.13.tar.gz
    cd libelf-0.8.13
    ./configure --disable-shared --enable-static --prefix=/tmp/gcc
    make && make check && make install
    

    GCC

    GCC is the GNU Compiler Collection. It depends on GMP, MPFR, MPC, and ELF.

    wget http://www.netgull.com/gcc/releases/gcc-4.6.2/gcc-4.6.2.tar.gz
    tar zxvf gcc-4.6.2.tar.gz
    

    Build gcc in a scratch directory on the same mount point. (Building it within /tmp would trigger cross compile host issues)

    mkdir -p /opt/downloads/gcc-4.6.2-scratch
    cd /opt/downloads/gcc-4.6.2-scratch
    

    The configure command and its flags must be all on one command line (this post shows them on separate lines just because of web page width).

    Note: We use the full path to configure and do not set library path environment variables. We choose to disable bootstrap and disable shared libraries because we don't want them (typical users may want both), and to use posix threads and to flags that are defaults because we want them (typical users may want to use other threads or skip default flags). YMMV and read about the flags here

    /opt/downloads/gcc-4.6.2/configure
      --disable-shared
      --disable-bootstrap
      --disable-libstdcxx-pch
      --enable-languages=all
      --enable-libgomp
      --enable-lto
      --enable-threads=posix
      --enable-tls
      --with-gmp=/tmp/gcc
      --with-mpfr=/tmp/gcc
      --with-mpc=/tmp/gcc
      --with-libelf=/tmp/gcc
      --with-fpmath=sse
    make && make install
    

    This page is great for GCC installation info, how to build it, various flags, and more:

    http://www.acsu.buffalo.edu/~charngda/cc_build.html

    Updates

    The ppl libraries can be used for memory optimizations: see bugseng.com/products/ppl/Download (Thanks Paul in comments)

    You could run ./contrib/download_prerequisites from the gcc source directory. (Thanks to N7P on reddit)

    这篇关于如何安装GMP,MPFR,MPC,ELF,无需共享库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆