autotools: fix C++ compile flags

This sets the flags "-g -O2". For C code these are set
automatically by the autotools but we need them for C++ as well.
We've noticed this while trying to debug a segfault with
"objdump -S".