Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when i compile an iOS project with using the three part library, i got "Apple Mach-O linker Error"

Tags:

ios

linker

mach-o

I've added a library named "*.a" from three part and added its header file in my XCode project. While I compile the project, there are many "Apple Mach-O linker Error". Here the error info:

"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)

Any one help me to fix this issue. Thanks!

like image 789
Qijin Avatar asked Mar 16 '14 13:03

Qijin


Video Answer


3 Answers

Looks like the library uses C++. Try adding libstdc++ to your target.

like image 83
Phillip Mills Avatar answered Oct 16 '22 13:10

Phillip Mills


Thanks it helped me to repair my project, during switching from SDK 6 to SDK 8 had the same errors.

With adding libstdc++6 i could solve my problem.

like image 27
Imeksbank Avatar answered Oct 16 '22 13:10

Imeksbank


Try changing the C++ Standard Library from Compiler Default to libstdc++ (GNU C++ standard library) in the Target --- > Build Settings --> C++ standard library

This solved my problem .

like image 1
iGW Avatar answered Oct 16 '22 13:10

iGW