Revert "Revert "compile with gcc47 and fix errors for it""

This reverts commit 2ee7ae00a5e274884bdd4fbd6f6df5ec8f7bccee.