One should follow a specific order to compile GCC, making sure that all dependencies are compiled properly. Some dependencies depend on others. In general the packages required to compile GCC properly are
Essential prerequisites:
Autoconf
Automake
M4
Direct Dependencies
GMP (requires -cxx option)
PPL (dep: GMP)
MPFR (dep: GMP)
MPC (dep: GMP, MPFR)
CLOOG-PPL (dep: GMP,PPL)
Install GMP first
============
./configure --prefix=/home/users/d/dr/droidzone/hostusr --enable-cxx
make ; make install[/code]Install PPL next
============
PPL depends on GMP, so specify its location./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp-prefix=/home/users/d/dr/droidzone/hostusr[/code]
make ; make installInstall MPFR
============
./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr
make ; make install[/code]Now, Install MPC
================
Install MPFR and GMP first, and then specify their path for MPC!
./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr
make ; make install[/code]Now, install CLOOG-PPL (For Graphite Loop Optimizations)
========================
./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr[/code]Now, Install GCC
================
export LD_LIBRARY_PATH=/home/users/d/dr/droidzone/hostusr/lib:$LD_LIBRARY_PATH[/code]./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr --disable-multilib[/code]Finally I found that GCC needs Glibc. Glibc needs Binutils!
Now, Install Binutils
================
./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr--with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr
make ; make install
[/code]You have to do a make clean if you get errors
Errors likely
However, with this, I got a specific error after around 10 minutes of building!
checking for x86_64-unknown-linux-gnu-gcc... /home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -B/home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/ -B/home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/bin/ -B/home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/lib/ -isystem /home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/include -isystem /home/users/d/dr/droidzone/hostusr/x86_64-unknown-linux-gnu/sys-include
checking for suffix of object files... configure: error: in `/home/users/d/dr/droidzone/depend/gcc-4.6.2/x86_64-unknown-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[2]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/users/d/dr/droidzone/depend/gcc-4.6.2'
make: *** [all] Error 2
[/code]
This means you had to pass LIB path.Then I got another one..
In file included from /home/users/d/dr/droidzone/depend/gcc-4.6.2/host-x86_64-unknown-linux-gnu/gcc/include-fixed/features.h:361:0,
from /usr/include/stdio.h:28,
from ../../.././libgcc/../gcc/tsystem.h:87,
from ../../.././libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
[/code]FIX
===./configure for gcc with --disable-multilib[/code]./configure --prefix=/home/users/d/dr/droidzone/hostusr --with-gmp=/home/users/d/dr/droidzone/hostusr --with-ppl=/home/users/d/dr/droidzone/hostusr --with-cloog=/home/users/d/dr/droidzone/hostusr --with-mpc=/home/users/d/dr/droidzone/hostusr --with-mpfr=/home/users/d/dr/droidzone/hostusr --disable-multilib[/code]For this, the following bit of information is useful:
Some other useful info:
Libraries have been installed in:
/home/users/d/dr/droidzone/hostusr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'[/code]Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.