LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to install all g++ versions & switch 4.5,4.6,4.7 in Debian Wheezy? -alternatives? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-install-all-g-versions-and-switch-4-5-4-6-4-7-in-debian-wheezy-alternatives-4175416791/)

esgol 07-15-2012 01:48 AM

How to install all g++ versions & switch 4.5,4.6,4.7 in Debian Wheezy? -alternatives?
 
As I was told Debian Wheezy provides 4 g++ instalations.

When i had apt-get install g++ only g++4.7 was installed

How can i install the former 3 also?

Does that -alternatives command i cought around has something to do with?

Or it to late now that my 1st intalation was the latest g++ 4.7?

John VV 07-15-2012 03:02 AM

the different versions will be in the repos BUT under a slightly different name

just do a search for gcc and the others WILL be on the list



to use "alternatives" or to not use "alternatives" that is the question ....

some like it i do not
in /usr/bin there should be a link from /usr/bin/g++4.7 to /usr/bin/g++
or what ever the default it

i use a set up script
YOURS WILL BE A BIT DIFFERENT depending on just WHAT you have installed
-- my gcc 4.6 script called " set_gcc_to_4.6.sh" ---
Code:

#!/bin/bash
rm /usr/bin/cpp
ln -s /usr/bin/cpp-4.6 /usr/bin/cpp
echo ln -s cpp-4.6 cpp

rm /usr/bin/gcc
ln -s /usr/bin/gcc-4.6 /usr/bin/gcc
echo ln -s gcc-4.6 gcc

rm /usr/bin/cc
ln -s /usr/bin/gcc-4.6 /usr/bin/cc
echo ln -s gcc-4.6 cc

rm /usr/bin/g++
ln -s /usr/bin/g++-4.6 /usr/bin/g++
echo ln -s g++-4.6 g++

rm /usr/bin/c++
ln -s /usr/bin/g++-4.6 /usr/bin/c++
echo ln -s g++-4.6 c++

rm /usr/bin/gcov
ln -s /usr/bin/gcov-4.6 /usr/bin/gcov
echo ln -s gcov-4.6 gcov

use one for EVERY version
and edit the linking and removing to YOUR system

then as root run the script for the one you want

you will find that most software will need a bit of help to build in gcc4.7
it is SO NEW that most things have not caught up to it yet

4.5 is most likely the version you will most use

esgol 07-15-2012 03:14 AM

omg starts becoming complex :S
I'm a beginner to linux and stuck when comes to commands.
I would like to have what commands exactly shall i write line by line to have eg g++4.5 also installed

But afraiding of asking to much, if I can't figure further myself I may give it away

P.S.
However The -alternatives way i had cought somewhere appeared easier, no?

knudfl 07-15-2012 03:22 AM

Quote:

When I had apt-get install g++ only g++4.7 was installed
Yes, g++ is g++ version 4.7.

# apt-get install g++-4.4 g++-4.5 g++-4.6
... will install the other.

About using : You have been told that information in another post.
Example : # update-alternatives --config gcc
And of course the temporary export command :
export CC=gcc-4.4 CXX=g++-4.4 && <other-command>
etc. etc.

And please use # 'apt-cache search <name>' ( or part of name )
when you are searching for packages. ( apt-cache search g++ ).
Synaptic will show all versions too. ( # apt-get install synaptic ).

.

esgol 07-15-2012 04:16 AM

So 1st i install the other versions

and 2nd i create the alternatives.

knudfl 07-15-2012 05:44 AM

Quote:

and 2nd i create the alternatives.
There seem to be no gcc entries in the Wheezy /etc/alternatives.

For daily use it's also much faster to rely on the temporary export commands.


All times are GMT -5. The time now is 12:33 PM.