Compiles with g++, linker errors with gcc and clang. Running g++'s a.out produces some results but fails