2

I was wondering if it is possible to install multiple versions of g++ on the same machine without any problem.

I use the almost current gcc for my work(4.6.1). Now for my studies, my teacher has given us an incomplete project to complete and he says we should install gcc 3.4.3 .

please note that I have already read this : Is it possible to install 2 different versions of GCC at the same time? but I don't know what PATH I should set.

Moreover, I would like to use eclipse for both version. So I may need some guidance for that settings too.

Thank you very much

user8128167
  • 6,929
  • 6
  • 66
  • 79
rahman
  • 4,820
  • 16
  • 52
  • 86
  • 1
    You set the PATH to include the directory where you installed the one GCC version you wish to use. That should for the most part take care of things. gcc-3.4.3 is horribly old btw, if that project you have depends on it it might be that it is written in a non-standard way (like it might use deprecated headers like `iostreamh.h` and buddies). – Benjamin Bannier Oct 24 '12 at 07:26

2 Answers2

3

In bash you could do two scripts like this: first one:

export PATH=/path/to/your/3.4.3/bin:$PATH
eclipse&

and

export PATH=/path/to/your/4.6.1/bin:$PATH
eclipse&

By running one of those, eclipse should use first gcc it finds in your path. Also your default gcc should still be primary, if you don't run any scripts.

BTW: You can probably strike a deal with your professor on what c++ standard he wants you to use (and what libraries), not what outdated version of compiler you should use to compile your code.

dbrank0
  • 9,026
  • 2
  • 37
  • 55
  • thanks dud. Professor is out of reach :) so I am going to install old gcc in a separate directory. Just wanted to check: if I use a .deb package to install the old gcc, will it install on a default location9and mess up with my current gcc) or it will be possible to install it in the current directory? – rahman Oct 24 '12 at 07:51
  • 2
    You probably won't succeed in installing and using such an old GCC. It has dependency on very old Libc versions etc etc.... – Basile Starynkevitch Oct 24 '12 at 07:52
  • @BasileStarynkevitch yep, I am beginning to get a taste of it.... I guess I want to listen to you people and try to fix the code itself. – rahman Oct 24 '12 at 08:37
  • Don't last your time to port GCC 3.4.3 on your system. Talk to your professor, he probably would accept some code compiled by a more recent GCC.... Porting GCC 3.4.3 to your system may require weeks of useless work, .... – Basile Starynkevitch Oct 24 '12 at 09:07
  • I agree it's waste of time. For the sake of argument I tried to build 3.4.3 with recent gcc (4.6.3), and the thing fails. – dbrank0 Oct 24 '12 at 09:56
1

If you are using some Linux distribution, you can install several versions of GCC; for instance on Debian or Ubuntu you could install both gcc-4.6 and gcc-4.7 (the exact versions available depend upon the actual distribution).

Notice that GCC 3.4.3 is a very ancient version of the compiler (it has been released in november 2004). You may have trouble to install such an ancient version of GCC on your machine. Notice also that recent GCC (last version is 4.7) gives much better warnings, optimizations, and standard conformance than ancient version.

Of course, you don't need eclipse to use GCC. You could use some plain editor like gedit or emacs, and compile either on a command line (if you have only one file) or using a builder like make.

I would not bother installing GCC 3.4.3 on a recent machine (i.e. any Linux distribution from the last few years), because you could spend more than a week in installing such an old thing, and still fail. I would use the latest GCC available on that machine, always compile with -Wall -g and ask (or tell) my teacher about it.

Learn also to use the gdb debugger, and some version control like git.

The hints I gave here are probably relevant to you.

Community
  • 1
  • 1
Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547