Opened 8 years ago
Last modified 5 years ago
#11182 new Bugs
Iostreams can't find symbol only on OSX
| Reported by: | Owned by: | Jonathan Turkanis | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | iostreams |
| Version: | Boost 1.57.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
System: Darwin Kernel Version 14.3.0
Compiler: GCC 4.9
Boost version: Tried with 1.55, 1.57, 1.58-beta, boost-trunk of today
Minimal example:
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/iostreams/stream.hpp>
int main () {
boost::iostreams::stream<boost::iostreams::file_descriptor> fdstream;
return 0;
}
Outcome:
$ /usr/local/bin/g++-4.9 -I /opt/boost/include/ -L /opt/boost/lib/ -lboost_iostreams -o foo foo.cpp
Undefined symbols for architecture x86_64:
"boost::iostreams::file_descriptor::seek(long, std::_Ios_Seekdir)", referenced from:
std::fpos<__mbstate_t> boost::iostreams::detail::seek_device_impl<boost::iostreams::any_tag>::seek<boost::iostreams::file_descriptor>(boost::iostreams::file_descriptor&, long, std::_Ios_Seekdir, std::_Ios_Openmode) in ccr82hhn.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Change History (3)
comment:1 by , 7 years ago
comment:2 by , 6 years ago
This is a typical problem of a library being compiled with clang++ but then linked to objects generated by g++. This fails in case of the boost libraries. If you want to use them with g++, you have to compile them using g++. (Note that "brew install boost" delivers you a boost library compiled by clang++.)
comment:3 by , 5 years ago
I encountered this error on macOS, after installing Boost 1.66.0 using brew install boost. Since this by default links to clang compiler, switch to gcc and reinstall using brew install boost --cc=g++-7, substituting for your gcc. This took quite a while, so let brew do it's thing.

boost stable 1.59.0 – the problem still persists