Saturday, June 11, 2011

Compiling g++ for C++0x on CentOS

CentOS 5 (I don't recall the minor version I am using) includes g++ 4.1, however you cannot do C++0x development without g++ 4.4 or higher. Here's what I did:

Dependencies



First download the dependencies gmp-5.0.2, mpfr-3.0.1, mpc-0.9, ppl-0.11.2, cloog-ppl-0.15.11 (see http://gcc.gnu.org/install/prerequisites.html)

gmp


./configure --enable-cxx
make
make check
sudo make install


mpfr


./configure --with-gmp=/usr/local
make
make check
sudo make install


mpc


./configure --with-gmp=/usr/local
make
make check
sudo make install


ppl


./configure --with-gmp=/usr/local
make
make check
sudo make install

Grab some coffe, food, go for a stroll, etc. during make, this one takes a while (or at least it does in a VM)

cloog-ppl


./configure --with-gmp=/usr/local --with-ppl=/usr/local
make
make check
sudo make install


gcc



Download gcc (I used gcc-4.5.3), gcc-core, and g++

Then from the PARENT directory of where you extracted gcc:
mkdir gccbuild
cd gccbuild
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
../gcc-4.5.3/configure --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local --with-ppl=/usr/local --with-cloog=/usr/local
make -j 2
# go to sleep
make check
make install

2 comments:

  1. you could even install "g++44" from yum repo...
    do a
    #sudo yum install gcc44 gcc44-c++ libstdc++44-devel
    ~~~~~
    and you are good to go

    ReplyDelete
  2. Yup it works, but don't forget to change your compiler from g++ to g++44

    ReplyDelete