1

Would installations of gcc 4.7 and 4.8 peacefully coexist on the same machine? This would initially be a machine with Ubuntu 12.10 (Quantal Quetzal) but may extend it to other machines and distributions later, possibly even my mac (it would be 4.8 and the last supplied apple gcc on Mountain Lion). I am trying to test gcc's improved diagnostics in 4.8 comparing them to clang's, hence my need for gcc 4.8.

How do you invoke each installation of gcc if the answer to the above is yes?

haziz
  • 12,994
  • 16
  • 54
  • 75

3 Answers3

4

First off: Yes, you can have multiple installations of gcc on your machine.

If you install gcc from the default Ubuntu repositories you can call the different versions using gcc-4.6, gcc-4.7, .... The Ubuntu toolchain test repository ubuntu-toolchain-r/test has a gcc-4.7 package. AFAIK it does not have a gcc-4.8 package yet. There exist other repositories which maintain gcc packages (even for the current 4.8 development versions; just google for ubuntu gcc repository).

Other than that you can always also compile gcc from source ( http://gcc.gnu.org/install/index.html ) and have multiple versions ( http://gcc.gnu.org/faq.html#multiple ).

muehlbau
  • 1,897
  • 13
  • 23
2

According to the gcc FAQ you can install multiple versions. Take a look at this link http://gcc.gnu.org/faq.html#multiple

mathematician1975
  • 21,161
  • 6
  • 59
  • 101
2

If you build GCC yourself (be sure to have the build directory outside of the source directory), you can e.g. ../gcc-trunk-srcdir/configure it with e.g. --program-suffix=-trunk (and possibly some --prefix) then it will be installed as gcc-trunk, g++-trunk etc. So you can have multiple versions of GCC installed.

However, I suggest avoiding compiling a program with a mixture of GCC. Use the same GCC for compiling a given application or library. Be aware that you might encounter minor incompatibilities around the libstdc++ library.

Don't forget the --enable-plugins option to a recent GCC (sadly this option is not enabled by default, IIRC). You might even be tempted to try MELT (a high level domain specific language to extend GCC).

On some distributions, a recent snapshot of GCC trunk might be packaged as gcc-snapshot

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