Search code examples
c++linkerstatic-linking

C++ linking problems, seems like I can't link against standard C++ stuff


I am trying to use a library I've compiled myself in an iOS app. The library is the Tesseract OCR lib. It seems like compiling that (and its dependencies) have gone ok.

However, when I try to link against this lib in my app project, the app fails to link. The link errors surprise me; it seems like there are problems with the Tesseract stuff finding pretty standard C++ stuff.

Any suggestions about what I might be doing wrong would be most helpful.

Here is a snippet of the kind of link errors I'm seeing.

Undefined symbols for architecture armv7:
"std::string::find_last_of(char const*, unsigned long) const", referenced from:
  tesseract::WordSizeModel::Init(std::string const&, std::string const&) in    libtesseract.a(word_size_model.o)
"std::string::find_first_of(std::string const&, unsigned long) const", referenced from:
  tesseract::CubeUtils::SplitStringUsing(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> >*) in libtesseract.a(cube_utils.o)
"std::string::find_first_not_of(std::string const&, unsigned long) const", referenced from:
  tesseract::CubeUtils::SplitStringUsing(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> >*) in libtesseract.a(cube_utils.o)
"std::string::data() const", referenced from:
  tesseract::CubeUtils::SplitStringUsing(std::string const&, std::string const&, std::vector<std::string, std::allocator<std::string> >*) in libtesseract.a(cube_utils.o)
"std::string::find(char, unsigned long) const", referenced from:
  tesseract::TessLangModel::IsLeadingPunc(int) in libtesseract.a(tess_lang_model.o)

Solution

  • Thank you everyone for your answers. I found out what my particular problem was, so will share it here in case anybody else hits it.

    My problem was a project build setting. Under "Apple LLVM Compiler 5.0 - Language - C++" there is a setting for "C++ standard library". Its value needed to be changed to "Compiler Default".

    Several hours wasted, but problem solved!