如何在没有共享库的情况下,使用 GMP、MPFR、MPC、ELF 逐个安装 GCC? [英] How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries?

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

问题描述

如何使用当前版本逐个安装 GCC(GNU 编译器集合),
使用正确版本的依赖项,不使用包管理器(如 yum、rpm、apt、dpkg),也不使用共享库?

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?

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

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).

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

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

  • 我想要一个完全独立的 GCC,它可以在我的系统中移动,而无需使用任何共享库,也无需创建任何共享库.
  • 这就是 GCC 所说的困难的方式",不建议普通用户使用.

GCC 取决于:

  • GMP:GNU 多精度算术库
  • MPFR:GNU 多精度浮点舍入库
  • MPC:GNU 多精度 C 库
  • ELF:可执行和可链接格式库
  • PPL:帕尔马多面体库(可选,用于内存优化)

推荐答案

The Easy Way

如果您是典型的开发人员,则可以使用 http://中的说明以简单的方式安装gcc.gnu.org/wiki/InstallingGCC 或您的系统包管理器,例如:

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

艰难的道路

GCC 说这里的答案是艰难的方式",因为它逐个构建所有内容,并且不使用共享库.

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 基础设施:

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

--disable-shared 标志可能值得仔细研究,具体取决于您的需要.我使用 --disable-shared 因为我只构建静态代码,我想确保我不构建任何共享代码.我的需要是在我的驱动器周围轻松移动生成的 GCC,所以我想要所有静态代码,我不想要任何共享代码.如果您更喜欢共享代码,请省略 --disable-shared 标志.

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.

当您运行此答案中的任何命令时,请务必更新命令以使用符合您需求的当前 GCC 版本号.此答案中的命令适用于 GCC 4.6.2.

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.

请注意 GCC 文档说:虽然所需工具的任何足够新的版本通常都可以工作,但库要求通常更严格.在某些情况下,较新的版本可能有效,但使用记录的确切版本更安全."

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 是 GNU 多精度算术库.

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 是 GNU 多精度浮点舍入库.这取决于GMP.

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 是 GNU 多精度 C 库.这取决于GMP和MPFR.

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

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 是 GNU 编译器集合.这取决于 GMP、MPFR、MPC 和 ELF.

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

在临时目录中构建 gcc相同的挂载点.(在/tmp 中构建它会触发交叉编译主机问题)

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

configure 命令及其标志必须全部在一个命令行上(这篇文章将它们显示在单独的行中,只是因为网页宽度).

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).

注意:我们使用全路径配置,不设置库路径环境变量.我们选择禁用引导程序和禁用共享库,因为我们不想要它们(典型用户可能想要两者),并使用 posix 线程和默认标志,因为我们想要它们(典型用户可能想要使用其他线程或跳过默认标志).YMMV 并在此处

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

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

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

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

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

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

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

这篇关于如何在没有共享库的情况下,使用 GMP、MPFR、MPC、ELF 逐个安装 GCC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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