Default to lib=stdlibc++ for clang++ on Mac OS Mavericks with Xcode?

c++, clang++, macos

Solution

`MACOSX_DEPLOYMENT_TARGET` may be what you are looking for.

`export MACOSX_DEPLOYMENT_TARGET=10.8` should make `clang` to default to `libstdc++` instead of `libc++`.

Problem

I'm running MacOS X Mavericks with Xcode 5.1.1 including the command line tools. I'm compiling simple C++ programs using clang++ supplied with Xcode, the version info is: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) What I find is that if I try to run the following command clang++ -o hello.out hello.cpp I get the following errors: ``` Undefined symbols for architecture x86_64: "std::ios_base::Init::Init()", referenced from: ___cxx_global_var_init in hello-2ad0da.o "std::ios_base::Init::~Init()", referenced from: ___cxx_global_var_init in hello-2ad0da.o "std::cout", referenced from: _main in hello-2ad0da.o "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from: _main in hello-2ad0da.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) ``` If I change the command to clang++ -o hello.out -stdlib=libstdc++ hello.cpp I don't get any errors. Is there a way to make "-stdlib=libstdc++" the default for clang++, either with some configuration setting or some environment variable? Also, just for my information, why do I get the error?

Original source