Change toolchain to GCC 4.7 and fix build errors