Find the answer to your Linux question:
Results 1 to 3 of 3
My Red Hat Linux system came preinstalled with GCC 3.2.x installed in /usr (i.e. the executable in /usr/bin, the libraries in /usr/lib, etc.). I wanted to upgrade it, so I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Posts
    23

    How to (safely) have multiple GCC installations on the same machine?


    My Red Hat Linux system came preinstalled with GCC 3.2.x installed in /usr (i.e. the executable in /usr/bin, the libraries in /usr/lib, etc.). I wanted to upgrade it, so I downloaded the source for GCC 3.4.x and built and installed it in /usr/local. Now I have two versions of GCC on the same machine. Whenever I wanted to switch compiler I just modify the PATH environment variable to search either /usr/bin first or /usr/local/bin first. My questions are:

    (1) Is this a safe way to have multiple GCC installations on the same machine and to switch between GCC installations? Why?

    (2) Please describe all the alternative methods for having multiple GCC installations on the same machine and their pros and cons.

    (3) If I want to uninstall either GCC installations, what is the best way to do that? And how do I ensure that I completely remove all traces of the uninstalled version?

    Thanks for all the help I can get,

  2. #2
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401
    Yes, you can do that...

    First: if you compile gcc from sources, there's no problem.

    Each version that you have installed, rename it's executable with its version (i.e. gcc-3.3 gcc-4.0...), then use the symbolic link. The link should point to the current version of gcc you want use.
    (This work perfectly on my Debian, wich has a program alternative system)

    configure scripts first check from gcc program, wich will point to the current version you use.

    If I want to uninstall either GCC installations, what is the best way to do that? And how do I ensure that I completely remove all traces of the uninstalled version?
    make uninstall from the sources... it shoul be included.
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

  3. #3
    Just Joined!
    Join Date
    Jun 2005
    Posts
    23
    a) GCC has a -V option to switch between versions. (Does this means I have to install both versions to the same prefix, like /usr/ ?) Is this a better way than the one I'm using?

    What I'm really after is I don't want to mix libraries when building an executable (i.e. link some libraries from one version and link some other libraries from another version into the executable). Which libraries get linked depend on which libpath gets searched first, /usr/lib or /usr/local/lib. Libpaths are specified in makefiles, which there are many (and automatically generated) for a large project. Manually changing the libpaths in all of these makefiles is not practical, not to mention error-prone, such as not changing ALL libpaths. What I'm looking for is an easy, and safe, way to switch compilers without worrying whether a compile-time linking error or a run-time segmentation fault error is due compilers mix-up.

    b) Is it safe to use the rpm command to uninstall the preinstalled compiler version? Some of the libraries in /usr/lib are used by programs other than gcc. Will they be removed?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •