Linker error with boost::iostreams

Hello,

I get a linker error after trying to compile with clang++ a program using boost::iostreams. I've reduced the issue to a minimal case, as detailed below:

$ cat test.cpp #include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file.hpp>

int main(void)
{
    namespace io = boost::iostreams;
    io::stream<io::file> test("");
}

$ g++ test.cpp && echo Success Success

$ clang++ test.cpp /tmp/cc-fe0zit.o: In function `std::fpos<__mbstate_t> boost::iostreams::detail::seek_device_impl<boost::iostreams::streambuf_tag>::seek<std::basic_filebuf<char, std::char_traits<char> > >(std::basic_filebuf<char, std::char_traits<char>

&, long long, std::_Ios_Seekdir, std::_Ios_Openmode)':

test.cpp:(.gnu.linkonce.t._ZN5boost9iostreams6detail16seek_device_implINS0_13streambuf_tagEE4seekISt13basic_filebufIcSt11char_traitsIcEEEESt4fposI11__mbstate_tERT_xSt12_Ios_SeekdirSt13_Ios_Openmode+0x138): undefined reference to `std::basic_streambuf<char, std::char_traits<char>

::pubseekoff(long, std::_Ios_Seekdir, std::_Ios_Openmode)'

/tmp/cc-fe0zit.o:(.gnu.linkonce.r._ZTVN5boost9iostreams6detail16linked_streambufIcSt11char_traitsIcEEE+0x18): undefined reference to `std::basic_streambuf<char, std::char_traits<char>

::seekoff(long, std::_Ios_Seekdir, std::_Ios_Openmode)' clang: error:

linker command failed with exit code 1 (use -v to see invocation)

$ clang++ --version
clang version 2.9 (trunk 121486)
Target: i386-pc-linux-gnu
Thread model: posix

Thanks,

- Leszek

Pretty much a newbie to clang, but I believe this can be caused by clang not
being built with the proper configure option to specify where the libstdc++
library resides. I can confirm this problem occurs on Ubuntu 11.

You could try rebuilding using ./configure --with-gcc-toolchain=[path to
libstdc++].

I have also heard of people trying hacks like -L/usr/lib -lstdc++ but have
not been successful myself using this method.