Install and use multiple versions of gcc (on F15)
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2010
    Posts
    8

    Install and use multiple versions of gcc (on F15)

    For my work it is extremely useful to have multiple versions of gcc available. I've done this in the past under Ubuntu simply by enabling alternative or older repositories but in Fedora land I've not been able to find a standard automated way of doing this.

    Can anybody point me in the right direction?

  2. #2
    Join Date
    Mar 2006
    Location
    Silesia, Poland, EU
    Posts
    81

    Re: Install and use multiple versions of gcc (on F15)

    I haven't tested it on F15, but it was working well on previous versions if you install compat-gcc-34 package, and then simply modify env variable before running ./configure script like export CC=gcc34

    i hope it helps

    //edit

    ./configure --cc=gcc34 may also work in some cases

  3. #3
    Join Date
    Jan 2010
    Posts
    8

    Re: Install and use multiple versions of gcc (on F15)

    Thanks beer_hunter, I'd forgotten about that package and I think that will solve at least part of the problem.

  4. #4
    Join Date
    Aug 2005
    Location
    Ann Arbor
    Age
    51
    Posts
    3,947

    Re: Install and use multiple versions of gcc (on F15)

    i run gcc 4.5,4.3,4.1 and 3.4

    for setting them i use a shell script to make links from the different named files
    example to set the default cc to gcc4.5
    "set_compiler_4.5.sh"
    Code:
    #!/bin/bash
    rm /usr/bin/cpp
    ln -s /usr/bin/cpp-4.5 /usr/bin/cpp
    echo ln -s cpp-4.5 cpp
    rm /usr/bin/gcc
    ln -s /usr/bin/gcc-4.5 /usr/bin/gcc
    echo ln -s gcc-4.5 gcc
    rm /usr/bin/g++
    ln -s /usr/bin/g++-4.5 /usr/bin/g++
    echo ln -s g++-4.5 g++
    i have one for each

    mind you USE CAUTION with this
    OpenSUSE 13.2-64bit & Scientific Linux 6.6-64bit ( fedora 4 to 11) and 20 on KVM
    My Celestia Downloads

    h t t p ://celestiamotherlode.net/catalog/show_creator_details.php?creator_id=10

  5. #5
    Join Date
    Jan 2010
    Posts
    8

    Re: Install and use multiple versions of gcc (on F15)

    Hi JohnVV, using scripts to modify the links was the method I used under Ubuntu and would like to use again. The issue I have at the moment is getting the different versions installed -preferably without going through the tiresome process of compiling each one individually!

  6. #6
    Join Date
    May 2011
    Posts
    14

    Re: Install and use multiple versions of gcc (on F15)

    Hi Stretch

    Did you find a way to install an earlier version of gcc without compiling etc? If so could you let me know how as I need to do this as well.

    Regards

    JohnS

  7. #7
    Join Date
    Jan 2010
    Posts
    8

    Re: Install and use multiple versions of gcc (on F15)

    JohnS, unfortunately I've been hit with another problem. Gnome won't start up. Apparently it's called a fail whale.

    On another system at work I have a very crude solution which might help but I warn you, it's ugly! I've installed Ubuntu 10.10 which has 4.1, 4.3 and 4.4 in the repos. With that in place I share the project directories on the host system that I need to compile with other versions with the Ubuntu instance. It actually works quite nicely although it's certainly not what I'd call elegant.

    If you happen to find a better solution please post it since as this is still an open issue for me.

  8. #8
    Join Date
    May 2011
    Posts
    14

    Re: Install and use multiple versions of gcc (on F15)

    Hi Stretch

    I think I have given up as it is too much trouble and taking too much of my time.

    I tried installing "compat" packages which allows you to install older versions of gcc. You then call, for instance, gcc34 to invoke gcc version 3.4. The software I was running only called "gcc" though and I could not find a way to specify a different name. I tried renaming gcc34 to gcc but it ran into other problems on execution with not being able to find dynamic libraries. Some incompatibility but I do not know what. So I then tried going back to Fedora 13 which would have had the correct version of gcc for me. But that would not run with the nvidia drivers installed. So I have given up for now and gone back to Windows 7! I will have to wait for the software to catch up with Fedora 15!

    John

  9. #9
    Join Date
    Jun 2011
    Posts
    4

    Talking Re: Install and use multiple versions of gcc (on F15)

    Quote Originally Posted by JohnVV
    i run gcc 4.5,4.3,4.1 and 3.4

    for setting them i use a shell script to make links from the different named files
    example to set the default cc to gcc4.5
    "set_compiler_4.5.sh"
    Code:
    #!/bin/bash
    rm /usr/bin/cpp
    ln -s /usr/bin/cpp-4.5 /usr/bin/cpp
    echo ln -s cpp-4.5 cpp
    rm /usr/bin/gcc
    ln -s /usr/bin/gcc-4.5 /usr/bin/gcc
    echo ln -s gcc-4.5 gcc
    rm /usr/bin/g++
    ln -s /usr/bin/g++-4.5 /usr/bin/g++
    echo ln -s g++-4.5 g++
    i have one for each

    mind you USE CAUTION with this

    hi there

    i did installed gcc3.4.6 on fc15 .and now I have gcc34 and gcc in /usr/bin but not gcc-4.6.0 that come with fc 15 by default (I means that I can Compile with gcc that its version is 4.6.0) but I cant find /usr/bin gcc-4.6.0 or sth like that.

    so do you have any idea on fc15?

    I want to make one of them default gcc i tried by update-alternative but I was not successful .

  10. #10
    Join Date
    Aug 2005
    Location
    Ann Arbor
    Age
    51
    Posts
    3,947

    Re: Install and use multiple versions of gcc (on F15)

    there is a reason for the warning
    mind you USE CAUTION with this
    you might need to rename files and make links

    also it is just a "short-cut" to exporting the 3.4 or 4.1 version
    Code:
    export CC=gcc34
    also works
    now I have gcc34 and gcc
    depending on what you did
    that gcc might be a link to gcc34 and you messed up gcc 4.6

    you might need to reinstall the current gcc
    OpenSUSE 13.2-64bit & Scientific Linux 6.6-64bit ( fedora 4 to 11) and 20 on KVM
    My Celestia Downloads

    h t t p ://celestiamotherlode.net/catalog/show_creator_details.php?creator_id=10

  11. #11
    Join Date
    Jun 2011
    Posts
    4

    Arrow Re: Install and use multiple versions of gcc (on F15)

    hi there;
    john tanks for your reply ,i should explain my self like this:
    in ubuntu u an use update-alternative to define two or more different version of x item here gcc in /usr/bin you will have gcc and g++ and also the default version which is 4.4 in my 10.4 ubuntu soafter you install gcc-3.4.6 u use update-alternative and select gcc-3.4 and g++-3.4 as is now in /usr/bin just beside gcc,g++,gcc-4.4 so from know on if u use gcc u are compiling with default gcc that is gcc-3.4 unlesss you change it again in update-alternative , well the point is here ===> in fedora 10+ now fc15 there is update-alternative too but it dose not work and in /usr/bin you have just gcc,g++ which is by default version 4.6 and as u install gcc-3.4 it will be gcc-3.4,g++-3.4 and if u use update-alternative always version 4.6 will be loaded cause ther i s now gcc in between gcc-4.6 and gcc-3.4 to switch between them(I think)
    I should have act like ubuntu (make on as a default) and do not want to use cc=gcc34 or ./configure cc=gcc3.4 or the same.
    Last edited by forgotnote; 30th June 2011 at 01:19 AM.

  12. #12
    Join Date
    Mar 2006
    Location
    Silesia, Poland, EU
    Posts
    81

    Re: Install and use multiple versions of gcc (on F15)

    forgotnote

    in Fedora you can deal with that using CC enviromental variable, ie you want to compile using gcc34 (/usr/bin/gcc34) then use:
    export CC=gcc34

    this will make gcc-3.4 default compiler unless you unset the CC variable, it works same way with any other gcc version, binary must be called different than gcc however, thats why update-alternatives won't work here.

  13. #13
    Join Date
    Jun 2011
    Posts
    4

    Thumbs up Re: Install and use multiple versions of gcc (on F15)

    Thanx beer Hunter
    so i should eport CC=gcc{version or name} in my .bash_profile inorder to use my expected gcc .I didnot understand this part "binary must be called different than gcc however, thats why update-alternatives won't work here. " will you explain this more.it

  14. #14
    Join Date
    Aug 2005
    Location
    Ann Arbor
    Age
    51
    Posts
    3,947

    Re: Install and use multiple versions of gcc (on F15)

    you can ,the reason i use a script is things like cmake
    grab the default version .

    if the older versions are not in the repos , then build gcc ?.?
    its not hard
    OpenSUSE 13.2-64bit & Scientific Linux 6.6-64bit ( fedora 4 to 11) and 20 on KVM
    My Celestia Downloads

    h t t p ://celestiamotherlode.net/catalog/show_creator_details.php?creator_id=10

Similar Threads

  1. install multiple versions of GCC on Fedora 12
    By albertkao in forum EOL (End Of Life) Versions
    Replies: 4
    Last Post: 7th September 2011, 12:46 AM
  2. there are multiple versions...
    By drtv in forum Using Fedora
    Replies: 9
    Last Post: 18th December 2006, 03:05 AM
  3. Multiple versions of my sqlserver
    By javier2893 in forum Servers & Networking
    Replies: 5
    Last Post: 21st February 2006, 07:58 PM
  4. Downgrading gcc - or maybe multiple versions?
    By sebkg in forum Using Fedora
    Replies: 7
    Last Post: 12th August 2005, 03:39 PM
  5. Multiple versions of glibc
    By Severin in forum Using Fedora
    Replies: 2
    Last Post: 18th January 2005, 09:26 PM

Tags for this Thread

Posting Permissions

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