The following method comes from the Linux system administrator of our department. The credit should go to him.
It took me a while to get this figured out. Things have changed a good bit since I've last
compiled gcc. I got this to work on a CentOS x86_64 system:
# set this to your desired prefix
PREFIX=/local/duckwos/foobar
# extract sources
tar jxf gmp-4.3.1.tar.bz2
tar jxf mpfr-2.4.1.tar.bz2
tar jxf gcc-4.4.2.tar.bz2
# build 32-bit gmp
cd gmp-4.3.1
./configure --prefix=$PREFIX --enable-cxx ABI=32
make -j2
make -j2 check
make install
make distclean
# build 32-bit mpfr
cd ../mpfr-2.4.1
./configure --prefix=$PREFIX --with-gmp=$PREFIX
make -j2
make -j2 check
make install
make distclean
# build 64-bit gmp
cd ../gmp-4.3.1
mv $PREFIX/include/gmp.h $PREFIX/include/gmp-i386.h
./configure --prefix=$PREFIX --libdir=$PREFIX/lib64 --enable-cxx ABI=64
make -j2
make -j2 check
make install
# build 64-bit mpfr
cd ../mpfr-2.4.1
./configure --prefix=$PREFIX --libdir=$PREFIX/lib64 --with-gmp-include=$PREFIX/include --with-gmp-lib=$PREFIX/lib64
make -j2
make -j2 check
make install
# fix up gmp header files
mv $PREFIX/include/gmp.h $PREFIX/include/gmp-x86_64.h
cp /usr/include/gmp.h $PREFIX/include/gmp.h
# build gcc
cd ../gcc-4.4.2
mkdir build
cd build
export LDFLAGS="-L$PREFIX/lib64 -Xlinker -R$PREFIX/lib64"
export LD_OPTIONS="$LDFLAGS"
export LD_RUN_PATH=$PREFIX/lib64
../configure --prefix=$PREFIX --with-gmp-include=$PREFIX/include --with-gmp-lib=$PREFIX/lib64 --with-mpfr-include=$PREFIX/include --with-mpfr-lib=$PREFIX/lib64 --enable-shared --enable-threads=posix --enable-languages=c,c++
make -j2
make install
# tell linker to specify rpath
$PREFIX/bin/gcc -dumpspecs > $PREFIX/lib/gcc/x86_64-unknown-linux-gnu/4.4.2/specs
vi $PREFIX/lib/gcc/x86_64-unknown-linux-gnu/4.4.2/specs
Find the line that contains only "*link:".
On the next line, append the text:
%{!m32:-L/local/duckwos/foobar/lib64 -R/local/duckwos/foobar/lib64} %{m32:-L/local/duckwos/foobar/lib -R/local/duckwos/foobar/lib}
Save the file.
Then you should have a working compiler.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment