[cfe-dev] Current state of libcxx compatibility with libstdc++
Jeroen Ooms via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 9 03:03:27 PDT 2016
[ This is probably a FAQ, however Google gives a lot of conflicting and
outdated information... ]
We are trying to add support for compiling R packages with C++11 code on
CentOS 6/7 using standard compilers from CentOS/EPEL repositories. Because
gcc/libstdc++ on CentOS are too old (4.4.7), Tom Callaway has recently
added libcxx and libcxxabi [1,2] to Fedora/EPEL. We can now build C++11
code natively on CentOS with clang:
clang++ -stdlib=libc++ -std=c++11 example.cpp
Awesome. However for code which links to c++ system libraries (which are
compiled with gcc) this sometimes results in linking errors. For example a
test application geometry.cpp  which links to the
clang++ -stdlib=libc++ -std=c++11 geometry.cpp $(pkg-config --cflags
This fails with:
geometry.cpp:(.text+0xd9): undefined reference to
std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
geometry.cpp:(.text+0x2ed): undefined reference to
std::__1::char_traits<char>, std::__1::allocator<char> >() const'
Is this expected? Is there any way we can work around this to link c++
programs compiled with libcxx against system libraries which are compiled
with gcc? If not, might this be possible for future versions of libcxx or
are the two simply incompatible on this level?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev