To Install gcc-4.7 g++-4.7 on Raspberry Pi, enter the following commands:
$ sudo apt-get install gcc-4.7 g++-4.7
$ sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 –slave /usr/bin/g++ g++ /usr/bin/g++-4.6
$ sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 –slave /usr/bin/g++ g++ /usr/bin/g++-4.7
Then run the the command and select gcc-4.7.
$ sudo update-alternatives –config gcc
Original information found here.