How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries?
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.
Get the GCC infrastructure:
Put downloads in a temp directory (you can use whatever directory you want).
Build the infrastructure in a temp directory that is different than the downloads directory or its subdirectories:
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.
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 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 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 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 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 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:
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)
Building gcc of static library.(https://stackoverflow , How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries? - gcc. 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:
The accepted answer makes it far more complicated than necessary and is not correct for all versions. Building GCC with
--disable-shared is usually a very bad idea. See http://gcc.gnu.org/wiki/InstallingGCC for an easier approach.
The entire process should be no more difficult than this (replacing 4.6.2 with the version you want to build):
tar xzf gcc-4.6.2.tar.gz cd gcc-4.6.2 ./contrib/download_prerequisites cd .. mkdir objdir cd objdir $PWD/../gcc-4.6.2/configure --prefix=$HOME/GCC-4.6.2 make make install
(But please read the link above anyway, it contains useful information.)
Apparently some people on Ubuntu have tons of crap set in their environment which interferes with the GCC build process, and they need to remove that first:
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE LD_LIBRARY_PATH
How to Manually Build GNU Compiler Collection from Scratch on , How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries? (stackoverflow.com). submitted 7 months ago by TsukiZombina · comment; share; save. hide. report. no comments (yet). sorted by:. comment installer GCC (la collection de compilateurs GNU) morceau par morceau, en utilisant la version actuelle, utiliser les versions correctes des dépendances, ne pas utiliser un gestionnaire de paquets (comme yum, rpm, apt, dpkg), et ne pas utiliser de bibliothèques partagées?
[Mpc-discuss] mpc fails to build shared lib on powerpc64 linux, It builds piece by piece, and does not use shared libraries. we are going to need the following libraries and packages: GMP, MPFR, MPC, ELF and GCC. How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared libraries? 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 no
Used what Jonathan above has mentioned except that I had to download gmp and mpfr manually and create soft link (gcc 4.4.2 distribution probably does not have "download_prerequisites")
cd src/gcc-4.4.2 ln -s ~/linux64/gmp-4.2.1 gmp ln -s ~/linux64/mpfr-2.3.0 mpfr
Btw, using "-with-gmp" and "with-mpfr" with "./configure" gave me "configure: error: cannot compute suffix of object files: cannot compile". Hence I downloaded the srcs of gmp and mpfr and then created the soft link to it from within gcc src top leve dir
How to Build a GCC Cross-Compiler, One possible explanation > would be that there is no shared library for gmp or mpfr, /usr/local/lib/libgmp.so.10.0.2: ELF 64-bit MSB shared object, 64-bit I cd to my home dir where I also have a build dir for all these pieces needed. GNU checking dependency style of gcc gcc3 checking for gmp.h So, it appears that I have GMP 5.0.2 installed (but I built GCC with 5.0.1), and MPFR 3.1.0 (but I built GCC with 3.0.0) and MPC 0.9 (but I built GCC with 0.8.2). The mismatch comes about because I tried to compile and install GCC 4.6.2 and it presumably needed the newer versions. (I didn't succeed, but that's a different story.)
Installing GCC, How The Pieces Fit Together All the other packages we downloaded, such as MPFR, GMP and MPC, In the steps that follow, I'll install the new toolchain to /opt/cross . There's doesn't seem to a make rule that does this without having The static library is named libc.a and the shared library is libc.so . Re: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+. From: Satya Prakash Prasad <satyaprakash dot prasad at gmail dot com>; To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
User Jonathan Wakely, For most people the easiest way to install GCC is to install a package made trying to build GCC without reading the installation docs properly and make if GCC links dynamically to the GMP, MPFR or MPC support libraries then libraries must be in the dynamic linker's path, both when building gcc and GCC 5.3 install script from scratch (C-Shell). GitHub Gist: instantly share code, notes, and snippets.
You might remember me from such films as the GNU C++ Standard Library How to install GCC piece by piece with GMP, MPFR, MPC, ELF, without shared I've always done it as a separate operation, without reference to GCC (even though GCC triggered the rebuilds). I believe there may be a way to get GCC to build and install the libraries as it goes - by having the source for GMP, MPFR, MPC in the GCC source tree. Check the ./configure --help output for information.
Finding path of GMP and MPFR for gcc upgrade I've downloaded and extracted the source to /tmp/gcc-4.3.0 and created a directory /tmp/gcc430 When I run /tmp/gcc-4.3.0/configure I get the following output