Ubuntu – Multiple versions of gcc / g++ affects

12.04ccompilinggcc

I have a fairly simple question, and yet couldn't find an answer anywhere I looked.

In my workplace there is a CI server with ubuntu 12.04 installed, that server uses the default c/c++ binaries ( 4.6.3 ) versions of the compilers. There is now a project which requires new versions of the compilers ( ones that include c++11 ).

3 Questions:

  1. Will installing gcc-4.8 & g++4.8 break / change stuff which is used by the existing 4.6.3 versions ? ( maybe there are shared libs dependencies which can get overridden ? )

  2. Is it safe to assume gcc-4.8 & gcc-4.8 are not going to cause
    a situation where a build ( which relies on 4.6.3 ) passes, but in reality the build code behaviour changes ? ( maybe due to being optimized differently ? )

  3. Most importantly, Can several versions of the compilers be installed on a system without breaking previous versions of them ?

Please bear with me as c/c++ are not programming languages I ever got to work with.

Best Answer

  1. Will installing gcc-4.8 & g++4.8 break / change stuff which is used by the existing 4.6.3 versions ?

No.

  1. Is it safe to assume gcc-4.8 & gcc-4.8 are not going to cause a situation where a build ( which relies on 4.6.3 ) passes, but in reality the build code behaviour changes ? ( maybe due to being optimized differently ? )

Depends on how they rely on 4.6.3. Does your build process invoke gcc or gcc-4.6? If the latter, there shouldn't be any changes. If the former, you should use the alternatives system to configure gcc to use gcc-4.6, or change your processes to use gcc-4.6/g++-4.6. (Lookup update-alternatives.)

  1. Most importantly, Can several versions of the compilers be installed on a system without breaking previous versions of them ?

Yes, if you're installing using reasonably built debian packages. It's not unusual to have multiple versions of GCC installed.