PDA

View Full Version : Install and use multiple versions of gcc (on F15)



stretch
6th June 2011, 07:50 PM
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?

beer_hunter
6th June 2011, 08:58 PM
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

stretch
6th June 2011, 09:09 PM
Thanks beer_hunter, I'd forgotten about that package and I think that will solve at least part of the problem.

JohnVV
6th June 2011, 11:03 PM
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"


#!/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

stretch
7th June 2011, 08:49 AM
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!

JohnSeers
18th June 2011, 05:41 PM
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

stretch
19th June 2011, 05:44 PM
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.

JohnSeers
19th June 2011, 10:20 PM
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

forgotnote
24th June 2011, 05:16 PM
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"


#!/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?:confused:

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

JohnVV
24th June 2011, 07:31 PM
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

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

forgotnote
30th June 2011, 01:16 AM
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:confused::confused:)
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.
:D

beer_hunter
30th June 2011, 07:48 AM
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.

forgotnote
1st July 2011, 12:30 PM
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
:)

JohnVV
1st July 2011, 07:44 PM
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