[cfe-users] undefined references to libc++ inlines when linking executable

Christian Parpart trapni at gmail.com
Tue Feb 19 09:14:28 PST 2013


Hey all,

I am about to ensure that my C++11 code is also nicely compiling
with Clang and libc++ (both on trunk, older don't even come that far).

Now, everything compiles fine, but I cannot link, due to some really
strange errors (as you see below). lt complains about undefined references
to well defined methods. I've checked it, they do exist, but it still can't
find them.

The thing now is, doing the little test works just fine, but the actual code
is a little more complex, splitted up into 3 shared libraries, a few
plugins, and an executable.
And that executable does not link because of the following undefined
symbols....


../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_istream<char, std::char_traits<char> >& std::operator>><char,
std::char_traits<char> >(std::basic_istream<char, std::char_traits<char>
>&, char&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_streambuf<char, std::char_traits<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::push_back(char)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::assign(std::string const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_ifstream<char, std::char_traits<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::locale::~locale()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>
>'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(unsigned long, char, std::allocator<char> const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_istream<char, std::char_traits<char> >& std::operator>><char,
std::char_traits<char>, std::allocator<char> >(std::basic_istream<char,
std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::compare(char const*) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, unsigned long, std::allocator<char> const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::~basic_string()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_filebuf<char, std::char_traits<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `std::istream&
std::istream::_M_extract<unsigned int>(unsigned int&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::compare(std::string const&) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_istream<char, std::char_traits<char> >& std::ws<char,
std::char_traits<char> >(std::basic_istream<char, std::char_traits<char>
>&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::assign(char const*, unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::find(char const*, unsigned long, unsigned long) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_ostream<char, std::char_traits<char> >&
std::__ostream_insert<char, std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__throw_out_of_range(char const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `std::basic_ios<char,
std::char_traits<char> >::init(std::basic_streambuf<char,
std::char_traits<char> >*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_ostringstream<char, std::char_traits<char>,
std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::copy(char*, unsigned long, unsigned long) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_Rep::_M_destroy(std::allocator<char> const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_istringstream<char, std::char_traits<char>,
std::allocator<char> >::basic_istringstream(std::string const&,
std::_Ios_Openmode)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_filebuf<char, std::char_traits<char> >::open(char const*,
std::_Ios_Openmode)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `std::string::clear()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::append(std::string const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_M_replace_aux(unsigned long, unsigned long, unsigned long,
char)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `VTT for
std::basic_ifstream<char, std::char_traits<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*,
std::_Rb_tree_node_base&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::ios_base::ios_base()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::operator=(std::string const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_M_leak_hard()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__basic_file<char>::~__basic_file()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::replace(unsigned long, unsigned long, char const*, unsigned
long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__detail::_List_node_base::_M_unhook()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::compare(unsigned long, unsigned long, char const*) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::resize(unsigned long, char)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::append(char const*, unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_ios<char, std::char_traits<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*,
std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_M_mutate(unsigned long, unsigned long, unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char>
>::str() const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::rfind(char, unsigned long) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::reserve(unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::ios_base::~ios_base()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::operator=(char const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_Rep::_S_create(unsigned long, unsigned long,
std::allocator<char> const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::find_first_of(char const*, unsigned long, unsigned long)
const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__throw_length_error(char const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `VTT for
std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>
>'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::find(char, unsigned long) const'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `std::basic_ios<char,
std::char_traits<char> >::clear(std::_Ios_Iostate)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, std::allocator<char> const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_filebuf<char, std::char_traits<char> >::close()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_istringstream<char, std::char_traits<char>,
std::allocator<char> >::~basic_istringstream()'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::__throw_logic_error(char const*)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(std::string const&)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `std::ostream&
std::ostream::_M_insert<unsigned long>(unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(std::string const&, unsigned long, unsigned long)'
../lib/libXzeroFlow.so.0.6.0: undefined reference to `vtable for
std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >'
../lib/libXzeroFlow.so.0.6.0: undefined reference to
`std::string::_Rep::_S_empty_rep_storage'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)


I first thought, that this is maybe due to the fact, that I am using
-fvisibility=hidden when building the 3 shared libraries, but that's not
the case,
as I've completely stripped visibility out and I still don't get my binrary
to link.
As a side node, everything works just fine when using GCC (4.6, 4.7) and
its libstdc++.

Does anyone know why ld is refusing to find these symbols (mostly inlined
anyways, btw) ?

Thanks in advance,
Christian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130219/5381bcfb/attachment.html>


More information about the cfe-users mailing list