As part of my (OSX) project, I am building boost::regex as a dynamic library. When I build and link without -fvisibility-inlines-hidden, everything works as expected.
To work around a bug in another external dependency, I need to turn this compiler switch on, however. Doing so results in lots of linker errors like this one
Undefined symbols for architecture x86_64:
"boost::re_detail::perl_matcher<__gnu_cxx::__normal_iterator<char const*,
std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<
char const*, std::string> > >, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >::find()", referenced from:
bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*,
std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<
char const*, std::string> > >, char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*,
std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>,
boost::match_results<__gnu_cxx::__normal_iterator<char const*, std::string>,
std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const*,
std::string> > > >&, boost::basic_regex<char, boost::regex_traits<char,
boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags,
__gnu_cxx::__normal_iterator<char const*, std::string>) in Regex.o
when I try to link boost to my project (the file "Regex.o" is part of the boost dylib). As I understand Apple's documentation, limiting inline visibility should just cause every dynamic lib to get its own instance of the inlined function, but should never cause linker errors.
It seems there is a related compiler bug for virtual methods, but neither perl_matcher::find()
nor regex_search()
are virtual methods.
Any suggestions/ideas?
$ clang --version
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix