c++ - Clang does not recognize std::shared_ptr with libstdc++ -
i have snippet:
#include <memory> int main() { std::shared_ptr<int> p(new int); }
if compile clang++ -std=c++0x -stdlib=libstdc++ main.cpp
error:
main.cpp:4:8: error: no fellow member named 'shared_ptr' in namespace 'std' std::shared_ptr<int> p(new int); ~~~~~^
it works when using stdlib=libc++
instead. version of libstdc++ 6.0.9 , compiler is
$ clang++ --version apple llvm version 5.1 (clang-503.0.40) (based on llvm 3.4svn) target: x86_64-apple-darwin13.3.0 thread model: posix
i see same result when using clang version 3.5.0 (tags/release_350/final)
.
i have realized works if utilize tr1
, seems less portable me:
#include <tr1/memory> int main() { std::tr1::shared_ptr<int> p(new int); }
so, isn't possible utilize std::shared_ptr
clang , libstdc++?
mac ships old version of gcc (4.2.1) of course of study comes old libstdc++. getting started page llvm says:
if intend utilize clang's c++ support, may need tell how find c++ standard library headers. in general, clang observe best version of libstdc++ headers available , utilize them - both scheme installations of libstdc++ installations adjacent clang itself. if configuration fits neither of these scenarios, can utilize --with-gcc-toolchain
configure alternative tell clang gcc containing desired libstdc++ installed.
this easiest way it, point modern gcc installation is. if don't want recompile clang, can seek follow instructions mailing list:
yes, of course. finding standard library no magic, can add together -isystem, -l, , perchance -wl,-rpath arguments clang++ when using it. utilize -v alternative see clang using default, can add together same s/4.4/4.7/g. if clang puts 1 of own directories first (before gcc ones), sure specify 1 time again still ends first. can seek flags -nostdinc++ clean bit (again, check -v list makes sense).
-- marc glisse
keep in mind if manage clang++ working newer libstdc++, libstdc++ , libc++ binary incompatible. means libraries (such boost) compiled 1 must recompiled other.
c++ c++11 clang++
No comments:
Post a Comment