Workaround autoconf bug and ensure a C++ compiler is mandatory

If AC_PROG_CXX is used after AC_PROG_CC, it will return "g++" even if no
C++ compiler is installed. However, as we need one, testing compiling a
program will make configure fail if indeed no C++ compiler is installed.