ld: symbol(s) not found for architecture x86_64
This is saying that 'ld', the linker, is not able to find definitions for some symbols your program uses. So you know compilation has succeeded.
And ld lists the specific symbols. Notice that they are all from the standard library. This should tell you that the standard library is probably not being found by the linker.
Typically when you use a library you have to tell the compiler toolchain using a link flag. But for a language's standard library the compilers in the GNU compiler collection generally just assume you want the library for that language. So running the gcc command automatically includes the C standard libraries, running g++ automatically includes the C++ standard libraries, etc. But notice, running 'gcc' does not automatically link in the C++ standard library. It's very likely that you're running the command 'gcc' and simply not adding the correct linker flag for the C++ standard library.
If for some reason you want to use gcc and not g++ you'll have to explicitly state that you want the standard library, using a flag like -lstdc++
.
Also, unless you really want gcc and you're installing the latest versions of it yourself on OS X you may want to switch over to clang/clang++ and the libc++ implementation of the C++ standard library. The gcc that comes with Xcode is based on an old version, and the standard library is similarly old. Xcode has been transitioning to clang as the system compiler for some time now. The clang compiler driver has basic compatibility with gcc so you use many of the same basic flags. Here's a good set to start with:
clang++ -std=c++11 -stdlib=libc++ -Wall -Wextra