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
[...] Quelle: http://risc0.wordpress.com/2007/03/04/nifty-script-for-gcc-default-version-fast-switching/ [...]