I have been trying to get C++11 to work, after browsing different websites and Q/A, i am still having trouble with. I want to use clang with libstdc++. It is indicated in th
You can use the special option -gcc-toolchain, which is implicitly set by --with-gcc-toolchain
when you compile clang. It's a bit easier than recompile clang when you want to use another GCC libraries :)
Like that:
~/clang/trunk/bin/clang++ main.cc -gcc-toolchain ~/gcc/trunk -o main
Or, in your case (I know it's 4 years old :)) it seems to be
clang++ main.cpp -o main -gcc-toolchain /opt/local
The 'toolchain' folder should contain 'include' and 'lib' folders. Both compiler and linker use this option. Be careful: --gcc-toolchain
is not a valid option, use one dash as the prefix (even though the llvm wiki states otherwise — I checked it on clang 3.8 trunk).
Why are you saying -I/opt/local/include/gcc47/c++
?
That should not be necessary with either GCC or Clang, and will not work. Not all libstdc++ headers are under that path, there are some essential headers elsewhere that define things like _GLIBCXX_BEGIN_NAMESPACE_VERSION
It doesn't fail with GCC because GCC already knows how to find the other headers, so it's redundant to explicitly use -I
and -L
options. It doesn't work with Clang because you are only telling it how to find some of the headers it needs, but not telling it how to find the rest.
Stop trying to override the compiler's standard library paths, let it use the built-in paths it already knows about.
I'm using clang-3.1 with gcc4.6 libstdc++ on FreeBSD 9.0/AMD64. It works with these options:
-I/usr/local/lib/gcc46/include/c++ \
-I/usr/local/lib/gcc46/include/c++/x86_64-portbld-freebsd9.0 \
-L/usr/local/lib/gcc46
I guess your problem may be solved to use these options:
-I/opt/local/include/gcc47/c++ \
-I/opt/local/include/gcc47/c++/x86_64-apple-darwin11.3.0 \
-L/opt/local/lib/gcc47