installing an older version of g++ on ubuntu 12.04

can someone guide me on how to install g++ say 3.6 version on ubuntu 12.04 which runs 4.x ?
A quick search on google will help

Here is a white paper on how to setup different versions of gcc

http://www.tellurian.com.au/whitepapers/multiplegcc.php

i had a problem compiling from source like you suggested , so i tried installing .deb from http://packages.ubuntu.com/hardy-updates/g++-3.4
i installed :
1
2
3
4
5
cpp-3.4_3.4.6-6ubuntu5_i386.deb  
gcc-3.4-base_3.4.6-6ubuntu5_i386.deb
g++-3.4_3.4.6-6ubuntu5_i386.deb  
libstdc++6-dev_3.4.6-6ubuntu5_i386.deb
gcc-3.4_3.4.6-6ubuntu5_i386.deb


but when i compile
1
2
3
4
5
6
7
#include <stdio.h>

int main(){
printf("hisss \n");

return 0;
}


using gcc-3.4 or g++-3.4 i get :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
In file included from /usr/include/stdio.h:28,
from ./hi.c:1:
/usr/include/features.h:324:26: bits/predefs.h: No such file or directory
/usr/include/features.h:357:25: sys/cdefs.h: No such file or directory
/usr/include/features.h:389:23: gnu/stubs.h: No such file or directory
In file included from /usr/include/stdio.h:34,
from ./hi.c:1:
/usr/lib/gcc/i486-linux-gnu/3.4.6/include/stddef.h:213: error: syntax error before "typedef"
In file included from ./hi.c:1:
/usr/include/stdio.h:36:25: bits/types.h: No such file or directory
In file included from ./hi.c:1:
/usr/include/stdio.h:49: error: syntax error before "typedef"
/usr/include/stdio.h:54: error: syntax error before "__USING_NAMESPACE_STD"
/usr/include/stdio.h: In function `__USING_NAMESPACE_STD':
/usr/include/stdio.h:65: error: storage class specified for parameter `__FILE'
In file included from /usr/include/_G_config.h:20,
from /usr/include/libio.h:32,
from /usr/include/stdio.h:75,
from ./hi.c:1:
/usr/include/wchar.h:95: error: storage class specified for parameter `__mbstate_t' 
and :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
In file included from /usr/include/libio.h:32,
from /usr/include/stdio.h:75,
from ./hi.c:1:
/usr/include/_G_config.h:24: error: syntax error before "__off_t"
/usr/include/_G_config.h:29: error: syntax error before "__off64_t"
/usr/include/_G_config.h:53: error: storage class specified for parameter `_G_int16_t'
/usr/include/_G_config.h:54: error: storage class specified for parameter `_G_int32_t'
/usr/include/_G_config.h:55: error: storage class specified for parameter `_G_uint16_t'
/usr/include/_G_config.h:56: error: storage class specified for parameter `_G_uint32_t'
In file included from /usr/include/libio.h:53,
from /usr/include/stdio.h:75,
from ./hi.c:1:
/usr/lib/gcc/i486-linux-gnu/3.4.6/include/stdarg.h:43: error: storage class specified for parameter `__gnuc_va_list'
In file included from /usr/include/stdio.h:75,
from ./hi.c:1:
/usr/include/libio.h:182: error: storage class specified for parameter `_IO_lock_t'
/usr/include/libio.h:302: error: syntax error before "__off_t"
/usr/include/libio.h:312: error: syntax error before "_IO_lock_t"
/usr/include/libio.h:340: error: syntax error before '}' token
/usr/include/libio.h:343: error: storage class specified for parameter `_IO_FILE'
/usr/include/libio.h:348: error: storage class specified for parameter `_IO_2_1_stdin_'
/usr/include/libio.h:349: error: storage class specified for parameter `_IO_2_1_stdout_'
/usr/include/libio.h:350: error: storage class specified for parameter `_IO_2_1_stderr_'
/usr/include/libio.h:366: error: storage class specified for parameter `__ssize_t'
/usr/include/libio.h:366: error: syntax error before "__io_read_fn"
/usr/include/libio.h:374: error: storage class specified for parameter `__ssize_t'
/usr/include/libio.h:374: error: redefinition of parameter '__ssize_t'
/usr/include/libio.h:366: error: previous definition of '__ssize_t' was here
/usr/include/libio.h:374: error: syntax error before "__io_write_fn"
/usr/include/libio.h:383: error: syntax error before "__off64_t"
/usr/include/libio.h:383: error: storage class specified for parameter `__io_seek_fn'
/usr/include/libio.h:386: error: storage class specified for parameter `__io_close_fn'
/usr/include/libio.h:418: error: syntax error before '*' token
/usr/include/libio.h:418: error: storage class specified for parameter `__underflow'
/usr/include/libio.h:419: error: syntax error before '*' token
/usr/include/libio.h:419: error: storage class specified for parameter `__uflow'
/usr/include/libio.h:420: error: syntax error before '*' token
/usr/include/libio.h:420: error: storage class specified for parameter `__overflow'
/usr/include/libio.h:462: error: syntax error before '*' token
/usr/include/libio.h:462: error: storage class specified for parameter `_IO_getc'
/usr/include/libio.h:463: error: syntax error before "_IO_FILE"
/usr/include/libio.h:463: error: storage class specified for parameter `_IO_putc'
/usr/include/libio.h:464: error: syntax error before '*' token
/usr/include/libio.h:464: error: storage class specified for parameter `_IO_feof'
/usr/include/libio.h:465: error: syntax error before '*' token
/usr/include/libio.h:465: error: storage class specified for parameter `_IO_ferror'
/usr/include/libio.h:467: error: syntax error before '*' token
/usr/include/libio.h:467: error: storage class specified for parameter `_IO_peekc_locked'
/usr/include/libio.h:473: error: syntax error before '*' token
/usr/include/libio.h:473: error: storage class specified for parameter `_IO_flockfile'
/usr/include/libio.h:474: error: syntax error before '*' token
/usr/include/libio.h:474: error: storage class specified for parameter `_IO_funlockfile'
/usr/include/libio.h:475: error: syntax error before '*' token
/usr/include/libio.h:475: error: storage class specified for parameter `_IO_ftrylockfile'
/usr/include/libio.h:492: error: syntax error before '*' token
/usr/include/libio.h:493: error: storage class specified for parameter `_IO_vfscanf'
/usr/include/libio.h:494: error: syntax error before '*' token
/usr/include/libio.h:495: error: storage class specified for parameter `_IO_vfprintf'
/usr/include/libio.h:496: error: storage class specified for parameter `__ssize_t'
/usr/include/libio.h:496: error: redefinition of parameter '__ssize_t'
/usr/include/libio.h:374: error: previous definition of '__ssize_t' was here
/usr/include/libio.h:496: error: syntax error before "_IO_padn"
/usr/include/libio.h:497: error: syntax error before '*' token
/usr/include/libio.h:497: error: storage class specified for parameter `_IO_sgetn'
/usr/include/libio.h:499: error: storage class specified for parameter `__off64_t'
/usr/include/libio.h:499: error: syntax error before "_IO_seekoff"
/usr/include/libio.h:500: error: storage class specified for parameter `__off64_t'
/usr/include/libio.h:500: error: redefinition of parameter '__off64_t'
/usr/include/libio.h:499: error: previous definition of '__off64_t' was here
/usr/include/libio.h:500: error: syntax error before "_IO_seekpos"
/usr/include/libio.h:502: error: syntax error before '*' token
/usr/include/libio.h:502: error: storage class specified for parameter `_IO_free_backup_area'
Try this article - it may help.

http://ubuntuforums.org/showthread.php?t=1682774

Remember to add the gcc paths to the /etc/ld.so.conf file, save, and run ldconfig to refresh lib search paths.

Topic archived. No new replies allowed.