matlab mex clang C++11 thread -> Undefined symbols error
Goal: I want to use thread STL of C++11 in Matlab mex file (R2013a) using Xcode 4.6 I modified ~/.matlab/R2013a/mexopts.sh CC='clang++' # was llvm-gcc-4.2 CXX='clang++' # was llvm-g++-4.2 MACOSX_DEPLOYMENT_TARGET='10.8' # was 10.5. C++11 is supported >=10.7 CXXFLAGS="$CXXFLAGS -std=gnu++11 -stdlib=libc++" # additional flags Normal mex files without C++11 features are compiled well. Further, STL is well detected by the compiler except linking failure. >> mex mextest.cpp Undefined symbols for architecture x86_64: "std::__1::__thread_struct::__thread_struct()", referenced from: void* std::__1::_