Friday, January 14, 2011

Compile gcc from souce on Ubuntu 10.04.1 LTS

To run C/C++ code using the mex utility of Matlab 7.11.0 (R2010b I needed to compile a different version of GCC than what was already installed on my machine. (I had the gcc version 4.4.1-4ubuntu9 and the currently supported version with mex is 4.3.4)

So I downloaded gcc-4.3 release from here.
Untarred the file: tar -jxvf gcc-4.3.4.tar.bz2

And now when I tried to use the ./configure from inside the gcc-4.3.4 folder, the system complained that it could not find two necessary API's namely GMP and MPFR.

The issue can be resolved by doing the following. We need to (1) download the GMP and MPFR libraries separately , (2) place them inside the GCC folder and then, (3) tell the configure script to look for it there.
tar -jxf gcc-4.3.2.tar.bz2
tar -jxf mpfr-2.3.2.tar.bz2
mv mpfr-2.3.2 gcc-4.3.2/mpfr
tar -jxf gmp-4.2.4.tar.bz2
mv gmp-4.2.4 gcc-4.3.2/gmp
cd gcc-4.3.2
./configure --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs
make
make install

Hopefully, that should solve the issues !