问题
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)
回答1:
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!
回答2:
I am using a newer version of the iOS SDK and set "Build Settings > Apple LLVM 5.0 - Language - C++ > C++ standard library" to "Compiler Default" but got 46 compile errors.
I got rid of the errors by setting it to "libstdc++ (GNU C++ standard library)".
Hopefully this helps anyone who got stuck when using "Compiler Default".
回答3:
Not sure if this will help anyone, but I had the same problem when I had a project linked with other projects when one had Base SDK as 5.1 and the other had Base SDK of 7.0.
回答4:
Maybe you do not have SDK for armv7 architecture, so you can compile your code but standard C++ stuff that installed on your computer is for another architecture (for example x86) and your linker can't find libraries that required for this architecture
回答5:
The link error suggests that the c++ library cannot be found in the path. Without further information, I would suggest checking the path to the c++ library is correct.
来源:https://stackoverflow.com/questions/12849517/c-linking-problems-seems-like-i-cant-link-against-standard-c-stuff