This is the case even with the old 4.2 GCC (I experienced this when I set up my unofficial iOS toolchain). gcc assumes C by default, and invokes the linker without linking to the C++ standard library; in contrast, g++ assumes C++ and links against the C++ standard library by default.
All in all – possible solutions:
gcc myprog.c -o myprog -lstdc++
or
g++ myprog.c -o myprog