gcc 4.8 on MAC OS X 10.8 throws "Undefined symbols for architecture x86_64: "
Solution 1:
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
Solution 2:
The answer to this stackoverflow question has the answer
gcc and g++ linker
Use
gcc -lstdc++ use_new.cpp -o use_new
The -lstdc++
flag tells the linker to include the C++ Standard Library
http://en.wikipedia.org/wiki/C%2B%2B_Standard_Library
I'm running Mac OS X 10.7.4 and the library is located here
/usr/lib/libstdc++.dylib