-   Linux - Software (
-   -   Is it safe to use non-default versions of gcc? (

swingliner 10-22-2011 10:13 PM

Is it safe to use non-default versions of gcc?
Hello. I've recently been playing around with CUDA on Ubuntu 11.10. Ubuntu 11.10's default gcc version is apparently 4.6, but CUDA only works with gcc up to version 4.4. It wasn't any problem installing the gcc-4.4 package and relinking /usr/bin/gcc to /usr/bin/gcc-4.4, and the CUDA example are working now. Though nothing has exploded yet, is this safe? Are dynamic libraries and object files compiled with one version of gcc compatible with those compiled with another?

Cultist 10-22-2011 10:30 PM

in general you'll be okay, but its possible that you have something installed (or will install something) that requires gcc 4.6 to run. But your computer isn't likely to explode anytime soon.

knudfl 10-23-2011 02:51 PM

The 3 compilers for Ubuntu 11.10 are : 1) The default /usr/bin/gcc
And the 2 "compat compilers" 2) gcc-4.4, 3) gcc-4.5 .

It should be possible in most situations to use 2) /usr/bin/gcc-4.4
and 3) /usr/bin/gcc-4.5 without relinking.

Examples : a) export CC=gcc-4.4 CXX=g++-4.4 && <other command>
b) ./configure CC=gcc-4.4 CXX=g++-4.4
c) make CC=gcc-4.4 CXX=g++-4.4

inclusivedisjunction 10-24-2011 03:36 AM

You can also use update-alternatives to switch between them without having to create a new link.


sudo update-alternatives --config gcc

All times are GMT -5. The time now is 11:23 AM.