views:

1184

answers:

1

I tried to install gcc 4.5 on ubuntu 10.04 but failed. Here is a compile error that I don't know how to solve. Is there anyone successfully install the latest gcc on ubuntu? Following is my steps and the error message, I'd like to know where is the problem....

Step1: download these files:

gcc-core-4.5.0.tar.gz
gcc-g++-4.5.0.tar.gz
gmp-4.3.2.tar.bz2
mpc-0.8.1.tar.gz
mpfr-2.4.2.tar.gz

Step2: Unzip above files

Step3: move gmp, mpc, mpfr to the gcc-4.5.0/ directory.

mv gmp-4.3.2  gcc-4.5.0/gmp
mv mpc-0.8.1  gcc-4.5.0/mpc
mv mpfr-2.4.2 gcc-4.5.0/mpfr

Step4: go to gcc-4.5.0 directory and do configuration:

sudo ./configure

Step5: compile and install

sudo make
sudo make install

The first 4 steps is OK, I can configure it successfully. However, when I try to compile it, following error message comes out, I cannot figure out what the problem is. Should I change the name from "gcc 4.5" to "gcc"?? It's a little strange that we need to do this by ourself. Is there anything I missed during the installation?

xxx@xxx-laptop:/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0$ sudo make
[sudo] password for xxx: 
[ -f stage_final ] || echo stage3 > stage_final
/bin/bash: line 2: test: /media/Data/Tool/linux/gcc: binary operator expected
/bin/bash: /media/Data/Tool/linux/gcc: No such file or directory
make[1]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[3]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
rm -f stage_current
make[3]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[2]: Entering directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
Configuring stage 1 in host-x86_64-unknown-linux-gnu/intl
/bin/bash: /media/Data/Tool/linux/gcc: No such file or directory
make[2]: *** [configure-stage1-intl] Error 127
make[2]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/media/Data/Tool/linux/gcc 4.5/gcc-4.5.0'
make: *** [all] Error 2
+4  A: 

It might not be a good idea to have a space in your path - it's kind of rare and can easily mess up shell scripts that aren't specially designed to deal with it (which is a bad combination!)

Another potential problem is that you're running configure inside the gcc source directory - this isn't recommended (and didn't work at all for me on at least one version of gcc 4). Instead make an empty build directory, parallel to the source directory, so you have something like:

gcc 4.5            <- but might want to avoid the space
  gcc-4.5.0
    ...
  build

Then cd into build and run

../gcc-4.5.0/configure

You may also need to start from a freshly unzipped source directory, as the previous failed build may have broken it.

Mike Dinsdale
Thanks a lot!! I can compile it now :) I think the main problem is the space in the path. BTW, I'm curious about why its recommended to use another folder to run the configuration. I do so as you said, if it's not too complicate, could you explain the reason to me ?
Claire Huang
To be honest, I don't know exactly why it breaks if you do the build in the source directory - presumably the build process overwrites a file from the source distribution or creates a new one that gets into the PATH and messes something up... but I'm really just guessing :) They might even have fixed it for `4.5`, but they're still recommending against it on the `gcc` website, so I wouldn't risk it (when I had the problem the build only failed after several hours of compiling, which is quite annoying :))
Mike Dinsdale
My understanding is that the developers build out-of-source; consequently they recommend you do too, since building in source is less tested and the build is non-trivial. Everyone has their preferences, but I prefer building out-of-source since it disambiguates the build artifacts from the source. This is probably less of an issue for someone who isn't doing development.
ejgottl