LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Building gcc 4.5.1 (https://www.linuxquestions.org/questions/linux-software-2/building-gcc-4-5-1-a-842567/)

Neruocomp 11-05-2010 10:52 AM

Building gcc 4.5.1
 
Building gcc isnt an easy task. I'm working on CentOS 5.5 and trying to build gcc 4.5.1. I built the preq libraries(gmp, mpc, mpfr) and binutils, all installed into the same directory(/opt/gcc-4.5.1). So I build gcc with the following configure options:

--with-mpc=/opt/gcc-4.5.1/ --with-gmp=/opt/gcc-4.5.1/ --with-mpfr=/opt/gcc-4.5.1/ --disable-shared --prefix=/opt/gcc-4.5.1/ --with-build-sysroot=/opt/gcc-4.5.1/ --with-build-time-tools=/opt/gcc-4.5.1/bin/

Note: I tried before without the disable-shared(which is used with all preq's) and would get an error about libgcc not finding the mpc library. So adding that option gets me farther but here is where I'm stuck:

Quote:

make[4]: Entering directory `/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/x86_64-unknown-linux-gnu/32/libgcc'
# If this is the top-level multilib, build all the other
# multilibs.
/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/./gcc/xgcc -B/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/./gcc/ -B/opt/gcc-4.5.1/x86_64-unknown-linux-gnu/bin/ -B/opt/gcc-4.5.1/x86_64-unknown-linux-gnu/lib/ -isystem /opt/gcc-4.5.1/x86_64-unknown-linux-gnu/include -isystem /opt/gcc-4.5.1/x86_64-unknown-linux-gnu/sys-include --sysroot=/opt/gcc-4.5.1/ -g -O2 -m32 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -I. -I. -I../../.././gcc -I../../../../../libgcc -I../../../../../libgcc/. -I../../../../../libgcc/../gcc -I../../../../../libgcc/../include -I../../../../../libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_TLS -o _muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c ../../../../../libgcc/../gcc/libgcc2.c \

In file included from ../../../../../libgcc/../gcc/libgcc2.c:29:0:
../../../../../libgcc/../gcc/tsystem.h:87:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make[4]: *** [_muldi3.o] Error 1
make[4]: Leaving directory `/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/x86_64-unknown-linux-gnu/32/libgcc'
make[3]: *** [multi-do] Error 1
make[3]: Leaving directory `/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/x86_64-unknown-linux-gnu/libgcc'
make[2]: *** [all-multi] Error 2
make[2]: Leaving directory `/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1/x86_64-unknown-linux-gnu/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/root/workspace/gcc/gcc-4.5.1/BUILD/gcc-4.5.1'
make: *** [all] Error 2

knudfl 11-05-2010 03:18 PM

The build of gcc-4.5.1 is well documented, and LQ members are building it all the time.
Most often as part of LFS http://www.linuxfromscratch.org/lfs/
> > LFS-BOOK-6.7 http://www.linuxfromscratch.org/lfs/downloads/stable/

From my notes, CentOS 5.5 / Scientific Linux SL55 :
Unpack gmp, mpfr, mpc into gcc-4.5.1/ and rename them to gmp/ mpfr/ mpc/ .
Go to the build directory outside gcc-4.5.1/ , and do
../gcc-4.5.1/configure --prefix=/usr/local/gcc451 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++ --disable-multilib --with-system-zlib --with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs

Requirements, probably # yum install \
gcc-g++ binutils-devel elfutils-libelf-devel glibc-devel
( You seem to be missing glibc-devel ? ).

make : No errors.


P.S. : /root/ should not be used for compiling.
/root/ is not meant to be used for anything.
Default is /home/<name>/tmp/ or any other folder in /home/<name>/.
..

Neruocomp 11-09-2010 03:05 PM

Linux from scratch is a good guide, but I finally got things working by using different versions of gmp and mpfr(4.3.2 and 2.4.2 respectively). Something about the latest versions being inserted into the gcc tree and they don't build write(mpfr cant find gmp). I did try building them outside the gcc tree and telling configure where they were, but then there were linking problems.

So downloaded gcc-4.5.1, untar, inserted gmp/mpfr/mpc and used configure --prefix=/opt/gcc-4.5.1 No other special build options and it works. Takes a long long LONG time but it works.

I do run 'make -k check' but that test_summery command doesn't give any output?

Neruocomp 11-09-2010 03:19 PM

I should also mention I'm building it a little closer to the guide. I first built gcc-4.3 in the manner I described before and used that to build binutils and glibc into a directory /opt/gcc-4.5.1-ver2 and configured gcc with the following:

--prefix=/opt/gcc-4.5.1-ver2 --enable-languages=c,c++,fortran --enable-threads=posix --enable-shared --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-bootstrap --with-system-zlib --with-build-time-tools=/opt/gcc-4.5.1-ver2/bin --with-build-sysroot=/opt/gcc-4.5.1-ver2/ --with-sysroot=/opt/gcc-4.5.1-ver2/

Its building right now and I'll report how it turns out.

Another question would be how would I setup a build environment that used /opt/gcc-4.5.1-ver2 instead of any of their lesser version numbered system programs? Simple as setting the PATH? Or what about LD_LIBRARY_PATH/LD_RUN_PATH? I'm fairly certain that I should go adding this to /etc/ld.so.conf since they are different from the system version.

knudfl 11-10-2010 03:37 PM

Lets start with the three default gcc for CentOS 5.5 :
# yum install g++ gcc44-c++ compat-gcc-34-c++
.. which will provide gcc-4.1.2 ( you already have it )
and gcc-4.4.0 , gcc-3.4.6 .

Using e.g. gcc-3.4.6 : 1) export CC=gcc34 CXX=g++34
2) <other command>

Gcc-4.5.1 cannot be added to your path : gcc is named 'gcc'.
The simple way of using it ( except for the full path ) is :
cd /usr/bin/
# ln -s /opt/gcc-4.5.1/bin/gcc gcc451
# ln -s /opt/gcc-4.5.1/bin/g++ g++451

GCC will usually know, where its own files are located.
'export CC=gcc451 CXX=g++451' should then be sufficient.

And you don't need a later binutils. 2.17.50 is OK.
Neither do you need another glibc.
Using anything different from glibc-2.5 will just make the
compiled results rather useless on CentOS. No glibc libraries can
ever be added to your path. The OS will stop working. Immediately.
..

ksp009 12-16-2010 07:24 AM

hi

i tried everyting....but same error has come........

knudfl 12-16-2010 07:53 AM

ksp009 , post # 6.

Please ask / answer in your own thread :
http://www.linuxquestions.org/questi...1/#post4192213

Did you read the two latest posts there ? ( #9 and #10 ).

..


All times are GMT -5. The time now is 09:30 PM.