当我使用三部分库编译iOS项目时,我得到了#Apple; Apple Mach-O链接器错误"

时间:2014-03-16 13:59:35

标签: ios linker mach-o

我从三个部分添加了一个名为“* .a”的库,并在我的XCode项目中添加了它的头文件。在我编译项目时,有许多“Apple Mach-O链接器错误”。这里有错误信息:

"std::ios_base::failure::~failure()", referenced from:

  "std::_List_node_base::unhook()", referenced from:

  "std::string::find(char const*, unsigned long, unsigned long) const", referenced from:

  "std::ios_base::failure::failure(std::string const&)", referenced from:

  "std::_List_node_base::hook(std::_List_node_base*)", referenced from:

  "std::invalid_argument::invalid_argument(std::string const&)", referenced from:

  "std::runtime_error::runtime_error(std::string const&)", referenced from:

  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(unsigned long, char, std::allocator<char> const&)", referenced from:

  "std::string::assign(char const*, unsigned long)", referenced from:

  "std::istream::operator>>(int&)", referenced from:

  "vtable for std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:

  "vtable for std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >", referenced from:

  "std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)", referenced from:

  "vtable for std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >", referenced from:

  "std::string::_Rep::_M_destroy(std::allocator<char> const&)", referenced from:

  "std::ios_base::Init::Init()", referenced from:

  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)", referenced from:

  "std::ostream& std::ostream::_M_insert<double>(double)", referenced from:

  "std::string::append(unsigned long, char)", referenced from:

  "std::string::_M_leak_hard()", referenced from:

  "std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:

  "std::string::find(char, unsigned long) const", referenced from:

  "std::string::find_last_not_of(char const*, unsigned long, unsigned long) const", referenced from:

  "std::string::replace(unsigned long, unsigned long, char const*, unsigned long)", referenced from:

  "std::string::reserve(unsigned long)", referenced from:

  "std::string::_M_mutate(unsigned long, unsigned long, unsigned long)", referenced from:

  "VTT for std::basic_ifstream<char, std::char_traits<char> >", referenced from:

  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:

  "non-virtual thunk to std::basic_istream<char, std::char_traits<char> >::~basic_istream()", referenced from:

  "std::string::_Rep::_S_terminal", referenced from:

  "std::string::_Rep::_S_max_size", referenced from:

  "std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)", referenced from:

  "std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long)", referenced from:

  "std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:

  "std::__throw_length_error(char const*)", referenced from:

  "std::string::append(char const*, unsigned long)", referenced from:

  "std::basic_istream<char, std::char_traits<char> >::~basic_istream()", referenced from:

  "std::string::compare(char const*) const", referenced from:

  "std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)", referenced from:

  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&, unsigned long, unsigned long)", referenced from:

  "std::basic_filebuf<char, std::char_traits<char> >::close()", referenced from:

  "std::basic_istringstream<char, std::char_traits<char>, std::allocator<char> >::basic_istringstream(std::string const&, std::_Ios_Openmode)", referenced from:

  "std::ios_base::Init::~Init()", referenced from:

  "vtable for std::basic_streambuf<char, std::char_traits<char> >", referenced from:

  "std::ios_base::~ios_base()", referenced from:

  "std::_Rb_tree_increment(std::_Rb_tree_node_base const*)", referenced from:

  "std::ostream::operator<<(int)", referenced from:

  "std::_Rb_tree_increment(std::_Rb_tree_node_base*)", referenced from:

  "std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const", referenced from:

  "std::istream& std::istream::_M_extract<float>(float&)", referenced from:

  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:

  "std::string::append(std::string const&)", referenced from:

  "std::string::find_first_of(char const*, unsigned long, unsigned long) const", referenced from:

  "std::__throw_out_of_range(char const*)", referenced from:

  "std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream()", referenced from:

  "std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)", referenced from:

  "std::locale::~locale()", referenced from:

  "std::string::_Rep::_S_empty_rep_storage", referenced from:

  "std::string::find_first_not_of(char const*, unsigned long, unsigned long) const", referenced from:

  "std::string::assign(std::string const&)", referenced from:

  "std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()", referenced from:

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

任何人都可以帮我解决这个问题。谢谢!

4 个答案:

答案 0 :(得分:6)

看起来这个库使用C ++。尝试将libstdc ++添加到目标中。

答案 1 :(得分:2)

感谢它帮助我修复了我的项目,从SDK 6切换到SDK 8时出现了同样的错误。

通过添加libstdc ++ 6,我可以解决我的问题。

答案 2 :(得分:1)

尝试将C ++标准库从Compiler Default更改为Target中的libstdc ++(GNU C ++标准库)---&gt;构建设置 - &gt; C ++标准库

这解决了我的问题。

答案 3 :(得分:0)

来自@Phillip Mills的答案很好地解决了许多错误,但不是为了终止所有错误而是将Apple LLVM 8.0下的C ++标准库设置 - 语言 - C ++更改为libstdc ++,如屏幕截图所示。我已经安全地从目标中删除了libstdc ++库。

Screenshot