Reputation: 185
I'm running the most up to date versions of clang++ (v3.1) and g++/gcc (v4.7.3) in Cygwin (32-bit). Everything is using the installed default configuration. This is a fresh install of Cygwin in Windows 8.
My issue is that clang++ cannot find the installed g++ STL headers to compile my project.
#include <stdlib.h>
#include <mutex>
#include <thread>
int main() {
std::mutex myMutext;
return 0;
}
This sample code results in this error when compiled. Notice the libc stdlib.h header compiles without error. It's that isn't found. I've tried other STL headers as a test, same error.
clang++ -c -o test.o test.cpp
test.cpp:2:10: fatal error: 'mutex' file not found
#include <mutex>
^
1 error generated.
After some searching it seems the suggested options are recompiling the entire clang project and adding the header paths to its source or manually adding all the g++ STL header paths to my makefile both of which seem kind of hacky.
There has to be an easier option, right?
Upvotes: 3
Views: 4511
Reputation: 1241
I don't know if you have solve it, but I have a simpler solution: just make s symlink of 4.7.3 to 4.5.3 and compile your code with -lstdc++ option, all will done.
Upvotes: 3
Reputation: 33212
clang++
will be build (compile-time) against specific versions of libstdc++
by default (IIRC). It will not check the system for newer versions at runtime.
The libstdc++
the clang-3.1
package of cygwin seems to use is gcc-4.5.3
, as indicated by the output of clang++ -v test.cc
. gcc-4.5.3
is not installed in your enviroment, however.
Your options, none of which are great:
gcc
to 4.5.3 via the setup. However your C++11 code will still not compile, due to lack of support in the libstc++
that comes with gcc-4.5.3
.clang
yourself, against the newer gcc
.clang
yourself, with libc++
. However, it is highly unlikely Windows is (fully) supported by it.gcc-4.7
instead. The Windows support is far more mature in gcc
right now anyway (and don't get me started about cross-compilers).(Aside: you'll need -std=c++11
to compile your code)
Upvotes: 1