WebFaction
Community site: login faq

My compiler is getting a bit rusty around the edges (again).

I want to install GCC 4.8 for "-std=c++11" C++11 support, better static and dynamic linking, with all of the Graphite Loop optimization options, with the full Scalable Whole-Program Optimizer, including and using the latest Binutils and GNU Multiprecision library, for all default languages (c, c++, fortran, java, objc).

It should compile hands-free on 64-bit CentOS 6 servers.

asked 05 Sep '13, 04:37

ryans ♦♦
5.0k93160
accept rate: 43%


According to GCC install documentation:

"What should be done is to untar the GCC source code, then in the source directory run ./contrib/download_prerequisites (which will download and untar MPFR, MPC and GMP in the same GCC source code directory as per the prerequisites documentation.)"

instead of installing prerequisite individually (MPFR, MPC, GMP, cloog. and isl), just do the following:

# replace version as appropriate version you use (I was building 4.9.2)

cd $HOME/gcc/src/gcc-4.9.2 
 ./contrib/download_prerequisites

Then it would be enough to run configure as follows:

../gcc-4.9.2/configure --prefix=$HOME/gcc --with-local-prefix=$HOME/gcc --with-system-zlib --with-gnu-as --with-gnu-ld --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-nls --disable-multilib
permanent link

answered 19 Feb '15, 19:33

cocofried
2612
accept rate: 100%

edited 19 Feb '15, 19:40

seanf
12.2k31836

Here you go. You can run these commands individually, or you can paste them into a shell script and run it as

bash buildgcc.sh | tee buildgcc.log

Either way, make sure you run it in a screen session.

#!/usr/bin/env bash
#
# Installs GCC. Run this in a screen session.
#

mkdir -p $HOME/bin $HOME/gcc/src $HOME/gcc/bin $HOME/gcc/lib

ln -s $HOME/gcc/lib $HOME/gcc/lib64  # only needed if we're on a 64-bit server.
  # we don't want to maintain two directories, and we're not using multilib.

set +h    # disable shell hashing so we can use binutils right away

# These are useful when running as a full script, to crash on any nonzero exit status
# However, in general, they should not be necessary for this guide.
# set -o errexit
# set -o nounset

# The dependencies are executed during gcc compilation; set run-time paths too
export PATH="$HOME/gcc/bin:$PATH"                       
export LD_LIBRARY_PATH="$HOME/gcc/lib:$LD_LIBRARY_PATH"

############################################################
# GNU Binutils
# Original: http://ftp.gnu.org/gnu/binutils/binutils-2.23.1.tar.bz2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/binutils-2.23.1.tar.bz2'
tar -xjf binutils-2.23.1.tar.bz2
mkdir binutils-2.23.1-build
cd binutils-2.23.1-build
../binutils-2.23.1/configure --prefix=$HOME/gcc --disable-werror
make          # 4 min
make check
make install

############################################################
# GNU MP Bignum Library 5.1.2
# Original: http://ftp.gnu.org/gnu/gmp/gmp-5.1.2.tar.bz2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/gmp-5.1.2.tar.bz2'
tar -xjf gmp-5.1.2.tar.bz2
cd gmp-5.1.2
CPPFLAGS=-fexceptions ./configure --prefix=$HOME/gcc --enable-cxx
make          # 2 min
make check    # 2 min
make install

############################################################
# GNU MFPR Library 3.1.2
# Original: http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/mpfr-3.1.2.tar.bz2'
tar -xjf mpfr-3.1.2.tar.bz2
cd mpfr-3.1.2
./configure --prefix=$HOME/gcc --with-gmp=$HOME/gcc
make          # 1.5 min
make check    # 2 min
make install

############################################################
# MPC Library 1.0.1
# Original: http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/mpc-1.0.1.tar.gz'
tar -xzf mpc-1.0.1.tar.gz
cd mpc-1.0.1
./configure --prefix=$HOME/gcc --with-gmp=$HOME/gcc --with-mpfr=$HOME/gcc
make          # 0.5 min
make check    # 1.5 min
make install

############################################################
# Parma Polyhedra (PPL) Library 1.0
# Original: http://bugseng.com/products/ppl/download/ftp/releases/1.0/ppl-1.0.tar.bz2
# Patch for GMP 5.1 compatibility: https://447928.bugs.gentoo.org/attachment.cgi?id=333770
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/ppl-1.0.tar.bz2'
tar -xjf ppl-1.0.tar.bz2
cd ppl-1.0
wget 'http://mirror.ryansanden.com/gcc-4.8/ppl-1.0.patch'
patch -p0 < ppl-1.0.patch
./configure --prefix=$HOME/gcc --with-gmp=$HOME/gcc
make          # 20 min
 #make check  # I killed it after 1hr 45min...
make install

############################################################
# CLooG-parma Library 0.16.1
# Original: http://www.bastoul.net/cloog/pages/download/count.php3?url=./cloog-parma-0.16.1.tar.gz
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/cloog-parma-0.16.1.tar.gz'
tar -xzf cloog-parma-0.16.1.tar.gz
cd cloog-parma-0.16.1
./configure --prefix=$HOME/gcc --with-ppl-prefix=$HOME/gcc --with-gmp-prefix=$HOME/gcc
make          # 20 sec
make check
make install

############################################################
# GCC 4.8.1
# Original: http://www.netgull.com/gcc/releases/gcc-4.8.1/gcc-4.8.1.tar.bz2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.8/gcc-4.8.1.tar.bz2'
tar -xjf gcc-4.8.1.tar.bz2
mkdir gcc-4.8.1-build
cd gcc-4.8.1-build

# Configure it.  See http://gcc.gnu.org/install/configure.html
../gcc-4.8.1/configure --prefix=$HOME/gcc --with-local-prefix=$HOME/gcc \
    --with-gmp=$HOME/gcc --with-mpfr=$HOME/gcc --with-mpc=$HOME/gcc \
    --with-ppl=$HOME/gcc --with-cloog=$HOME/gcc \
    --with-system-zlib --with-gnu-as --with-gnu-ld \
    --enable-clocale=gnu --enable-shared --enable-threads=posix \
    --enable-__cxa_atexit --disable-nls --disable-multilib \

make          # 2 hours
make install

############################################################
# Clean up & set Environment
############################################################
set -h
rm -r $HOME/gcc/src
cd $HOME/gcc/bin && ln -s gcc cc

echo 'export PATH="$HOME/gcc/bin:$PATH"' >> $HOME/.bashrc
echo 'export CPPFLAGS="-I$HOME/gcc/include $CPPFLAGS"' >> $HOME/.bashrc
echo 'export LDFLAGS="-L$HOME/gcc/lib $LDFLAGS"' >> $HOME/.bashrc
echo 'export LD_LIBRARY_PATH="$HOME/gcc/lib:$LD_LIBRARY_PATH"' >> $HOME/.bashrc

Enjoy!

permanent link
This answer is marked "community wiki".

answered 05 Sep '13, 04:39

ryans ♦♦
5.0k93160
accept rate: 43%

edited 05 Sep '13, 04:51

Just a note: I've seen issues with some dependencies for this guide, which seem to be programming errors in the dependencies themselves. The GCC 4.6 guide tends to work better.

(13 Oct '13, 03:24) ryans ♦♦

great script. Helped me alot

(14 Nov '13, 03:46) Karunakar

Hi, i have a problem.

Well. i try to use this script but i have the next errors:

ln: target «export LDFLAGS="-L$HOME/gcc/lib $LDFLAGS"» is not a directory

I don't know why happens it.

I am in the shell, and i write screen in the shell, then, in the screen shell I write bash buildgcc.sh | tee buildgcc.log. And then i have this issue, and i don't understand why. I have a screen session.

This is the full tack: [salahaddinal@web425 ~]$ bash buildgcc.sh | tee buildgcc.log mkdir: opción inválida -- s Pruebe `mkdir --help' para más información. buildgcc.sh: línea 14: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 15: ../binutils-2.22/configure: No existe el fichero o el directorio buildgcc.sh: línea 19: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 20: --prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio buildgcc.sh: línea 24: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 25: ../mpfr-3.1.0-allpatches.patch: No existe el fichero o el directorio make: *** No hay ninguna regla para construir el objetivo `install'. Alto. buildgcc.sh: línea 30: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 31: --with-mpfr=/home/salahaddinal/gcc: No existe el fichero o el directorio buildgcc.sh: línea 35: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 36: --with-gmp-prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio make: *** No hay ninguna regla para construir el objetivo `install'. Alto. buildgcc.sh: línea 42: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 43: --prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio buildgcc.sh: línea 47: cd: /home/salahaddinal/gcc/src: No existe el fichero o el directorio buildgcc.sh: línea 49: ../gcc-4.6.2/configure: No existe el fichero o el directorio ln: target «export LDFLAGS="-L$HOME/gcc/lib $LDFLAGS"» is not a directory

(17 Jan '15, 03:02) Yusuf Salah ...

Are you using '»' and not '>>'?

(18 Jan '15, 00:27) johns ♦♦

No, i'm using >>

(18 Jan '15, 19:15) Yusuf Salah ...

Not sure why I can't edit since it's marked community wiki, but the following should be known:

To run a screen session, type screen -S screensessionnameofyourchoice, then run the command above.

If on Windows and copying the script and then uploading it, make sure to use Notepad++ or similar to convert the line endings from Windows format to Unix format. Bash wasn't reading my script properly until I fixed this.

(13 Aug '15, 04:07) nrhinkle
showing 5 of 6 show 1 more comments

What have i do if the installation don't works? i have many problems, now i'm doing manually but i have this issues: No, it isn't the problem, now i am doing all manually. But, i have this problemas make a binutils library: make[4]: se sale del directorio /home/salahaddinal/gcc/src/binutils-2.25-build/ld' make[3]: se sale del directorio/home/salahaddinal/gcc/src/binutils-2.25-build/ld' make[2]: se sale del directorio /home/salahaddinal/gcc/src/binutils-2.25-build/ld' make[1]: No se hace nada paraall-target'. make[1]: se sale del directorio `/home/salahaddinal/gcc/src/binutils-2.25-build'

Same issue here:

make[2]: se sale del directorio /home/salahaddinal/gcc/src/gmp-6.0.0' make[1]: se sale del directorio/home/salahaddinal/gcc/src/gmp-6.0.0'

And others:

make[4]: No se hace nada para check-am'. make[4]: se sale del directorio/home/salahaddinal/gcc/src/gmp-6.0.0/demos/calc' make[3]: se sale del directorio /home/salahaddinal/gcc/src/gmp-6.0.0/demos/calc' Making check in expr make[3]: se ingresa al directorio/home/salahaddinal/gcc/src/gmp-6.0.0/demos/expr' make[3]: No se hace nada para check'. Making check in cxx make[2]: se ingresa al directorio/home/salahaddinal/gcc/src/gmp-6.0.0/cxx' make[2]: No se hace

And here: make[2]: se sale del directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/src' make[1]: se sale del directorio/home/salahaddinal/gcc/src/mpfr-3.1.2/src' Making all in tests make[1]: se ingresa al directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/tests' make[1]: No se hace nada paraall'. make[1]: se sale del directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/tests' Making all in tune make[1]: se ingresa al directorio/home/salahaddinal/gcc/src/mpfr-3.1.2/tune' make[1]: No se hace nada para all'. make[1]: se sale del directorio/home/salahaddinal/gcc/src/mpfr-3.1.2/tune' make[1]: se ingresa al directorio /home/salahaddinal/gcc/src/mpfr-3.1.2' make[1]: No se hace nada paraall-am'. make[1]: se sale del directorio `/home/salahaddinal/gcc/src/mpfr-3.1.2'

make[2]: se sale del directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/tests' make[1]: se sale del directorio/home/salahaddinal/gcc/src/mpfr-3.1.2/tests' Making check in tune make[1]: se ingresa al directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/tune' make[1]: No se hace nada paracheck'. make[1]: se sale del directorio /home/salahaddinal/gcc/src/mpfr-3.1.2/tune' make[1]: se ingresa al directorio/home/salahaddinal/gcc/src/mpfr-3.1.2' make[1]: No se hace nada para check-am'. make[1]: se sale del directorio/home/salahaddinal/gcc/src/mpfr-3.1.2'

permanent link

answered 18 Jan '15, 20:00

Yusuf Salah ...
113
accept rate: 0%

And this other! mp_std_bits.cc:31:1: error: unterminated #if mp_std_bits.cc:28:1: error: unterminated #if make[3]: [mp_std_bits.lo] Error 1 make[3]: se sale del directorio /home/salahaddinal/gcc/src/ppl-1.1/src' make[2]: *** [all] Error 2 make[2]: se sale del directorio/home/salahaddinal/gcc/src/ppl-1.1/src' make[1]: [all-recursive] Error 1 make[1]: se sale del directorio `/home/salahaddinal/gcc/src/ppl-1.1' make: *** [all] Error 2

(18 Jan '15, 20:01) Yusuf Salah ...

And this is try configure CLooG-parma Library 0.16.1. configure: error: Can't find PPL headers.

(18 Jan '15, 20:14) Yusuf Salah ...

Have you tried the 4.6 guide? As Ryan stated there tends to be dependency issues which are problems with them and not the guide.

(18 Jan '15, 22:18) johns ♦♦

i try it, but, the bash script in screen mode don't works.

(19 Jan '15, 02:04) Yusuf Salah ...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×15

question asked: 05 Sep '13, 04:37

question was seen: 5,063 times

last updated: 13 Aug '15, 04:07

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM