Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am using Ubuntu 10.04 and the current version of GCC installed in my system is 4.4. For some specific need I want to install GCC 3.2.

I began with these steps:

$mkdir gcc-build
$cd gcc-build
$tar zxvf gcc-3.2.tar.gz
$mkdir -p gcc-bin
$mkdir -p usr/local
$cd gcc-bin
$../gcc-build/gcc-3.2/configure --prefix=../gcc-build/usr/local

It has configured successfully. But when I used below command

$make bootstrap

I got an error

../gcc-build/gcc-3.2/gcc/read-rtl.c:653: error: lvalue required as increment operand
make[1]: *** [read-rtl.o] Error 1
make[1]: Leaving directory `../gcc-build/gcc-bin/gcc'
make: *** [all-gcc] Error 2

Anybody please help me to resolve this error. Or please suggest some alternative ways. Thanks.

share|improve this question
    
Why are building from source? –  i08in Feb 17 at 5:19
    
This is the only way I know to install older version of GCC. I tried using apt-get but it said that version 3.2 isn't available in the archive. Are there any alternative ways to install older version of gcc? –  Winn Feb 17 at 5:22
    
It seems that gcc has disallowed cast-as-lvalue. You have to modify sources by yourself if you only have modern binary release of gcc. –  House Zet Feb 17 at 5:43
    
Is it using current gcc 4.4 to actually compile gcc 3.2 ? –  Winn Feb 17 at 6:32
    
I think the problem is, as you pointed, maybe some syntax revision in later versions. Because make uses build-essentials and gcc, the possibility is that it is using gcc 4.4 to compile gcc 3.2. This might help askubuntu.com/questions/39628/old-version-of-gcc-for-new-ubuntu –  Ashish Gaurav Feb 17 at 11:34

2 Answers 2

Once I faced a similar problem. I had this module 'r8169' which wasn't receiving packets from my wired connection. Then I had to build the previous module 'r8168' from source. This gave me similar errors like yours.

A possible fix is by going into superuser mode. Type

sudo su

Then type your password. The console will show you '#' instead of '$' for writing commands. Then try your commands again.

#mkdir gcc-build
#cd gcc-build
#tar zxvf gcc-3.2.tar.gz
#mkdir -p gcc-bin
#mkdir -p usr/local
#cd gcc-bin
#../gcc-build/gcc-3.2/configure --prefix=../gcc-build/usr/local
# make bootstrap

(and any other commands, if left). Hopefully, it should work.

share|improve this answer
    
Well, if its a concern of superuser mode, I tried the same command lines in cygwin(under windows) as well(where default access is in superuser mode only). But there too, I am facing the same problem. –  Winn Feb 17 at 7:30
up vote 0 down vote accepted

After few trials, I found one solution.

I added below mirrors in /etc/apt/sources.list

deb http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb-src http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main
deb http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main
deb-src http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main

With these mirrors, I am able to install GCC 3.3(though not GCC 3.2) using

$sudo apt-get install g++-3.3   

Don't forget to do $sudo apt-get update before above command.

It is in fact satisfying my need. And to run the program using GCC 3.3, do

$gcc-3.3 input_file

Because otherwise if you type $gcc input_file it will use the default GCC(GCC 4.4 in my case) to compile the program. We can change the way desired version is used by simply creating a hard link of the version you want to tag to command gcc. We can do the following

$cd /usr/bin
$sudo ln gcc-3.3 gcc

So now whenever you type $gcc input_file it will use your desired gcc version to compile the program.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.