I'm trying to compile and link a simple program testing some C++11 features.
using namespace std;
int main(int argc, const char * argv)
unique_ptr\<string\> sp(new string("Hello world"));
cout \<\< *sp \<\< endl;
Running $icpc main.cpp -std=c++0x yields: main.cpp(9): catastrophic error: cannot open source file "mutex".
If I'm correct, icpc uses the c++ standard library of gcc, which by default is an old 4.2, even on an up-to-date OS X 10.8.
After installing gcc 4.7 from macports, the following worked: icpc main.cpp -std=c++0x -gcc-name=/opt/local/bin/gcc-mp-4.7 .
My problem now is to try and get it to compile in XCode. After switching the compiler to XE 13.0 and selecting -std=c++0x I add -gcc-name=/opt/local/bin/gcc-mp-4.7 to "Additonal C options". I then get a compilation error "file '/Applications/Xcode.app/Contents/Developer/usr/bin/opt/local/bin/gcc-mp-4.7' not found, generated based on '-dev-usr-root /Applications/Xcode.app/Contents/Developer/usr'". Apparently /Applications/Xcode.app/Contents/Developer/usr/bin/ is appended to the paths.
Trying to work-around it by adding a soft-link to /opt at /Applications/Xcode.app/Contents/Developer/usr/bin/opt improves the situation, but then instead I get catastrophic error: cannot open source file "mutex". I tried adding -gxx-name=/opt/local/bin/g++-mp-4.7 without any improvement.
A related post seems to have succeeded, but it doesn't seem to work for me on OS X 10.8, XCode 4.6.1 and ICC 13.0.2.
It would be greatly appreciated if you could post a step-by-step instruction of how to get C++11 working in XCode with XE 13, using a recent libstd++ and/or libc++. Right now, this is really a show-stopper for me using the intel compiler suite.The best thing would certainly be if you could make it work out of the box with libc++.
Thanks Sergey for the input.
> Usage of Intel C++ compiler option -std=c++0x doesn't mean that the compiler will "emulate" a content of "mutex" header file.
No, I guess it only enables to core language definition of C++11, but not the standard library (which contains <mutex>).
Correct me if im wrong: My understanding is that icc does not have an own standard library implementation, but uses libstd++ (or possibly libc++?) and that it gets the settings/location of that by calling gcc/clang. Thus, as mentioned in the original post, the command line version compiles when I execute icpc main.cpp -std=c++0x -gcc-name=/opt/local/bin/gcc-mp-4.7, which is a version that has C++11 support.
My real question is: Given an unmodified installation of the most recent versions of OS X, XCode and XE/ICC, how do I get icpc in XCode to compile arbitrary C++11 code that relies on C++11 standard library features (such as mutex from <mutex> or unique-ptr from <memory>. The included code is just an example.
This is really mostly a question on:
>The test case was successfully compiled with VS 2012 because it is the only VS version with std threading support. But it has some problerm with
I've verified that the code compiles an runs just fine on GCC 4.7.3 (installed from macports), OS X 10.8, XCode 4.6.1 and ICC 13.0.2. It's all standard c++11 code, so if it doesn't compile and run, it seems like a bug!?