A small note on the following rather cryptic GCC error:
undefined reference to `__gxx_personality_v0'
This generally means you're trying to compile a C++ program. While gcc can compile those programs, it cannot link them. Use g++ and the error goes away.