Monday, December 6, 2010

How to install gcc-3.3 in Ubuntu 9.04

Today I tried to install gcc-3.3 in Ubuntu9.04 in my PC. I followed following steps. I found 2 patches to solve the errors in the Internet.
(NOTE: - means delete, and + means add as in Patch file)

1. Download gcc-core3.3.tar.bz2 and gcc-g++-3.3.tar.bz2
2. bzip2 -cd gcc-core3.3.tar.bz2 | tar xvf -
bzip2 -cd gcc-g++-3.3.tar.bz2 | tar xvf -
3. mkdir build
4. cd build
5. /home/xxxx/gcc/gcc-3.3/configure --prefix=/opt/gcc33 --program-suffix=33 --enable-languages=c,c++

6. If there are errors from /usr/include/bits/studio-lock.h file
then comment the /*#include */
- #include
+ /*#include */
7. If there are errors from gcc/gcc-3.3/include/obstack.h file ("/read-rtl.c:653: error: lvalue required as increment operand")
Change line#423 in
gcc/gcc-3.3/include/obstack.h
- *((void **)__o->next_free)++ = ((void *)datum); \
+ *((void **)__o->next_free) = ((void *)datum);
+ __o->next_free += sizeof(void *); \
8. If there are errors from decl.c file
Apply gcc42-patch-gcc-3.3.1_gcc_cp_decl.c patch from ftp.nsysu.edu.tw/FreeBSD/FreeBSD-current/ports/palm/prc-tools/files/gcc42-patch-gcc-3.3.1_gcc_cp_decl.c
9. If there is an error "gcc/collect2.c:1779:/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared"
Then, in the line number 1776 of gcc/collect2.c
- redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);
+ redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0666);
10. make
11. Follow http://www.mjmwired.net/resources/mjm-fedora-gcc.html

Few useful commands
:
sudo apt-get install gcc
find /usr/bin |grep gcc
find /usr/bin |grep g++
stat /usr/bin/gcc

$ cd /usr/bin
The default gcc version
$ gcc --v

Delete the old symbolic links
$ sudo rm cpp gcc g++

Change the symbolic links to 3.3: (Find where the gcc33 is installed. In this example we installed in /opt/gcc33/bin (we gave the command while installing gcc as: --prefix=/opt/gcc33).

$sudo ln -s /opt/gcc33/bin/g++33 /usr/bin/g++
$sudo ln -s /opt/gcc33/bin/gcc33 /usr/bin/gcc
$sudo ln -s /opt/gcc33/bin/cpp33 /usr/bin/cpp

Check the default gcc version

$ gcc --v

It should show new gcc version.

5 comments:

Anonymous said...

Thanks a ton!! Have been struggling to install this for the last 2 days.

spyware said...

hey sir.. i'm newbie
can you explain step by step..
maybe the directory i should install

GP Joshi said...

Hi Spyware,
Sorry to reply late. It's given in the post, where you can install.

Cecil said...

Thanks for the help, I'm very close to getting it working I think. One problem, the patch file for decl fails:
Snip-
Hunk #4 succeeded at 568 with fuzz 2 (offset -236 lines).
Hunk #5 FAILED at 823.
Hunk #6 FAILED at 836.
Hunk #7 succeeded at 4287 (offset -249 lines).
END snip

I'm wondering if you happen to have a copy of a patched decl.c lying around, or perhaps a different version of the patch.

Any help is appreciated!

GP Joshi said...

Hi Cecil,
Sorry to reply late. Hope you have already succeeded on it. It's already been a year you asked the question.