osX下编译c++程序出现Undefined symbols for architecture x86_64的原因及解决

摘自stackoverflow.com

1.The error isn't that it's the wrong architecture, it's that std::cout (and other symbols) isn't defined.

You should compile and link with g++ not gcc, to automatically link with correct C++ libraries.



2.The error is caused because you're compiling with gcc, which only default-links libc. You need to compile with g++ so that libstdc++ is auto-linked in too.

你可能感兴趣的:(C++)