- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to compile and link a simple program testing some C++11 features.
main.cpp:[cpp]#include \<mutex\>
#include \<memory\>
#include \<iostream\>
using namespace std;
mutex m;
int main(int argc, const char * argv[])
{
lock_guard\<mutex\>l(m);
unique_ptr\<string\> sp(new string("Hello world"));
cout \<\< *sp \<\< endl;
return 0;
}[/cpp]
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++.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
- How is C++11 standard library setup recommended to be done in icpc on OS X (my solution is macports installation of gcc 4.7 and explicit usage of it, but is there some better/supported way)?
- Can one get libc++ (used by Apple) to work instead of libstdc++ (from GCC) as standard library implementation? That might increase compatibility with other Apple related code and wouldn't rely on a non-standard component (gcc 4.7)?
- How do I setup the XCode enviroment to make the above work, i.e. to include C++11 standard library header files and link to that C+11 standard library?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>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!?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page