nifty script for gcc default version fast switching

4 03 2007

Yesterday I was facing the problem about setting default GCC version on Debian GNU/Linux, so I googled for a while and thanks to this post of Jeff Carr on Debian GCC List I could do it fast and in a so elegant way.

It’s not unusual to have several gcc versions intalled on the system, in fact I have 4.1, 3.4 and 3.3, so after several hours (normally after so much) BitBaking an image, you could find some errors compiling a bloody package, that’s usually due to gcc version used natively, and that’s why I have switched to 3.3.6 hoping not to regret, I’ll tell you tomorrow…

I paste the script here for your convenience anyway.

#!/bin/bashusage() {

 echo

 echo Sets the default version of gcc, g++, etc

 echo Usage:

 echo

 echo "    gcc-set-default-version <VERSION>"

 echo

 exit

}

cd /usr/bin

if [ -z $1 ] ; then

 usage;

fi

set_default() {

 if [ -e "$1-$2" ] ; then

 	echo $1-$2 is now the default

 	ln -sf $1-$2 $1

 else

 	echo $1-$2 is not installed

 fi

}

for i in gcc cpp g++ gcov gccbug ; do

 set_default $i $1

done

Actions

Information

One response

26 07 2010

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.