1

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.

5
  • Why are building from source?
    – jobin
    Feb 17, 2014 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, 2014 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, 2014 at 5:43
  • Is it using current gcc 4.4 to actually compile gcc 3.2 ?
    – Winn
    Feb 17, 2014 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 Feb 17, 2014 at 11:34

3 Answers 3

2

Here is an incredibly hacky fix to work around the loss of cast-as-lvalue, based on a suggestion of SM Ryan in comp.lang.c.

Near the top of the file, add

#define LV(type,lvalue) (*((type*)((void*)(&lvalue))))

Now, replace the casts with LV(...) as in these examples (from gdb's obstack.h):

On line 428, change

*((void **)__o->next_free)++ = ((void *)datum);

to

*(LV(void**, __o->next_free))++ = ((void *)datum);

and likewise, on line 436 change

*((int *)__o->next_free)++ = ((int)datum);      

to

*(LV(int*, __o->next_free))++ = ((int)datum);

Good luck.

1
  • 1
    I used this technique to get GCC 3.1.1 to compile with GCC 6.3.0 and it worked. IMO this answer should be marked as the correct answer because it is the minimal workaround to achieve what the questioner asked for.
    – smammy
    Jan 21, 2022 at 19:16
0

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.

-1

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.

1
  • 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, 2014 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .