在iOS应用中Tesseract集成中的错误。

时间:2022-07-31 08:57:27

I am getting some errors while integrating Tesseract SDK in my iOS app. The procedure I have followed -

在我的iOS应用程序中集成Tesseract SDK时,我犯了一些错误。

1) Dragged "libtesseract_full.a" in xcode 2) Dragged "tessdata" folder in xcode 3) Dragged "baseapi.h" in xcode

1)libtesseract_full拖”。“在xcode 2中”拖拽了xcode 3中拖拽的tessdata文件夹。在xcode中h”

Now when I am using Tesseract -

现在当我使用Tesseract -。

// init the tesseract engine.
tess = new TessBaseAPI();

tess->SimpleInit([dataPath cStringUsingEncoding:NSUTF8StringEncoding],  // Path to tessdata-no ending /.
                 "eng",  // ISO 639-3 string or NULL.
                 false);

I am getting these below errors (I think there is some framework or something like that missing, but not getting what is missing, tesseract demo project is working fine on my system)

我在错误中得到了这些(我认为有一些框架或者类似的东西丢失了,但是没有得到丢失的东西,tesseract demo项目在我的系统上运行良好)

clang: warning: argument unused during compilation: '-stdc++'
ld: warning: CPU_SUBTYPE_ARM_ALL subtype is deprecated: /Users/saurabhsharma/Desktop/Tess/SnapXv2/libtesseract_full.a(libtesseract_full.o)
Undefined symbols for architecture armv7:
  "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
      SVNetwork::SVNetwork(char const*, int) in libtesseract_full.a(libtesseract_full.o)
  "std::_Rb_tree_decrement(std::_Rb_tree_node_base*)", referenced from:
      std::_Rb_tree_iterator<std::pair<char const* const, int> >::operator--() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<int const, VariableContent*> >::operator--() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >::operator--() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<int const, ScrollView*> >::operator--() in libtesseract_full.a(libtesseract_full.o)
  "std::string::operator+=(char const*)", referenced from:
      ScrollView::SendPolygon() in libtesseract_full.a(libtesseract_full.o)
  "std::ios_base::Init::Init()", referenced from:
      __static_initialization_and_destruction_0(int, int) in libtesseract_full.a(libtesseract_full.o)
      __static_initialization_and_destruction_0(int, int) in libtesseract_full.a(libtesseract_full.o)
  "std::string::size() const", referenced from:
      SVNetwork::Flush() in libtesseract_full.a(libtesseract_full.o)
  "std::__throw_length_error(char const*)", referenced from:
      std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&) in libtesseract_full.a(libtesseract_full.o)
  "std::string::erase(unsigned long, unsigned long)", referenced from:
      SVNetwork::Flush() in libtesseract_full.a(libtesseract_full.o)
  "std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)", referenced from:
      std::_Rb_tree<int, std::pair<int const, ScrollView*>, std::_Select1st<std::pair<int const, ScrollView*> >, std::less<int>, std::allocator<std::pair<int const, ScrollView*> > >::erase(std::_Rb_tree_iterator<std::pair<int const, ScrollView*> >) in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree<std::pair<ScrollView*, SVEventType>, std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> >, std::_Select1st<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >, std::less<std::pair<ScrollView*, SVEventType> >, std::allocator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > > >::erase(std::_Rb_tree_iterator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >) in libtesseract_full.a(libtesseract_full.o)
  "std::string::length() const", referenced from:
      SVNetwork::Flush() in libtesseract_full.a(libtesseract_full.o)
  "std::string::operator+=(char)", referenced from:
      ScrollView::SendPolygon() in libtesseract_full.a(libtesseract_full.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
      ScrollView::SendPolygon() in libtesseract_full.a(libtesseract_full.o)
      SVNetwork::SVNetwork(char const*, int) in libtesseract_full.a(libtesseract_full.o)
  "std::_Rb_tree_increment(std::_Rb_tree_node_base*)", referenced from:
      std::_Rb_tree_iterator<std::pair<int const, VariableContent*> >::operator++() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<char const* const, int> >::operator++() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<int const, ScrollView*> >::operator++() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >::operator++() in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<int const, ScrollView*> >::operator++(int) in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree_iterator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >::operator++(int) in libtesseract_full.a(libtesseract_full.o)
  "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::_Rb_tree<int, std::pair<int const, VariableContent*>, std::_Select1st<std::pair<int const, VariableContent*> >, std::less<int>, std::allocator<std::pair<int const, VariableContent*> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<int const, VariableContent*> const&) in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree<char const*, std::pair<char const* const, int>, std::_Select1st<std::pair<char const* const, int> >, std::less<char const*>, std::allocator<std::pair<char const* const, int> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<char const* const, int> const&) in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree<int, std::pair<int const, ScrollView*>, std::_Select1st<std::pair<int const, ScrollView*> >, std::less<int>, std::allocator<std::pair<int const, ScrollView*> > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<int const, ScrollView*> const&) in libtesseract_full.a(libtesseract_full.o)
      std::_Rb_tree<std::pair<ScrollView*, SVEventType>, std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> >, std::_Select1st<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > >, std::less<std::pair<ScrollView*, SVEventType> >, std::allocator<std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > > >::_M_insert(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::pair<std::pair<ScrollView*, SVEventType> const, std::pair<SVSemaphore*, SVEvent*> > const&) in libtesseract_full.a(libtesseract_full.o)
  "std::ios_base::Init::~Init()", referenced from:
      ___tcf_0 in libtesseract_full.a(libtesseract_full.o)
      ___tcf_0 in libtesseract_full.a(libtesseract_full.o)
  "std::string::c_str() const", referenced from:
      ScrollView::SendPolygon() in libtesseract_full.a(libtesseract_full.o)
      SVNetwork::Flush() in libtesseract_full.a(libtesseract_full.o)
  "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()", referenced from:
      ScrollView::SendPolygon() in libtesseract_full.a(libtesseract_full.o)
      SVNetwork::SVNetwork(char const*, int) in libtesseract_full.a(libtesseract_full.o)
  "std::string::append(char const*)", referenced from:
      SVNetwork::Send(char const*) in libtesseract_full.a(libtesseract_full.o)
  "std::cout", referenced from:
      SVNetwork::SVNetwork(char const*, int) in libtesseract_full.a(libtesseract_full.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any help would be appreciated.

如有任何帮助,我们将不胜感激。

4 个解决方案

#1


20  

just changed "C++ Standard Library" in build settings to "libstdc++ (GNU C++ standard library)" and errors are gone… Thanks @H2CO3 for hint.

只是将“c++标准库”更改为“libstdc++ (GNU c++标准库)”,错误就会消失,谢谢@H2CO3提示。

#2


1  

There are several issues:

有几个问题:

Firstly ensure the file containing the code:

首先确保包含代码的文件:

tess = new TessBaseAPI();
tess->SimpleInit(...);

has a file extension of .mm (Objective-C++) as it uses both Objective-C and C++.

在使用Objective-C和c++时,文件扩展为.mm (Objective-C++)。

Secondly the library looks like it hasn't been compiled for armv7, so you will need to rebuild it for any architectures you want to support, which will be one or more of armv6, armv7, armv7s and i386 (for the iPhone Simulator).

其次,该库看起来还没有为armv7编译,因此您需要为希望支持的任何体系结构重新构建它,这将是一个或多个armv6、armv7、armv7s和i386(用于iPhone模拟器)。

If you are targeting iOS 5.0+ then that will be all of the above apart from armv6 which isn't supported on later versions of Xcode.

如果你的目标是ios5.0 +,那么这将会是除了armv6之外的所有内容,而这在Xcode的后续版本中是不受支持的。

Thirdly, make sure you use the same version of C++ and C++ library in both the library and the app, otherwise bad things will happen.

第三,确保在库和应用程序中使用了相同版本的c++和c++库,否则会发生不好的事情。

#3


0  

Make sure:

确保:

C++ Language Dialect Set "Compiler Default" instead of "GNU++11[-std=gnu++11]"

c++语言方言设置“编译器默认”而不是“GNU++11[-std= GNU++11]”

C++ Standard Library Set "Compiler Default" instead of "libc++(LLVM C++ standard library with C++11 support)"

c++标准库设置“编译器默认”而不是“libc++(LLVM c++标准库,c++ 11支持)”。

Also check:

也检查:

C Language Dialect Set "C00 [-std=c99]" instead of "GNU00 [-std=gnu99]"

C语言方言设置"C00 [-std=c99]"而不是"GNU00 [-std=gnu99]"

and tesseract files should be referenced properly. (drag and drop files not reference properly)

tesseract文件应该被正确引用。(拖放文件不能正确引用)

#4


0  

ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  1. Change Project -> Project -> Build Settings -> **"Enable Bitcode" to NO

    更改项目->项目->构建设置-> **“启用位码”为NO。

  2. also remove all linker flags in "linking" -> "Other Linker Flags" and add this

    还可以删除“链接”->“其他链接标记”中的所有链接标记,并添加这个。

在iOS应用中Tesseract集成中的错误。 3. After that install pods by command "pod install"

3所示。在安装后,通过命令“pod安装”

It's works for me on Swift 2 and Xcode 7.2 (beta)

在Swift 2和Xcode 7.2 (beta)中对我有用

#1


20  

just changed "C++ Standard Library" in build settings to "libstdc++ (GNU C++ standard library)" and errors are gone… Thanks @H2CO3 for hint.

只是将“c++标准库”更改为“libstdc++ (GNU c++标准库)”,错误就会消失,谢谢@H2CO3提示。

#2


1  

There are several issues:

有几个问题:

Firstly ensure the file containing the code:

首先确保包含代码的文件:

tess = new TessBaseAPI();
tess->SimpleInit(...);

has a file extension of .mm (Objective-C++) as it uses both Objective-C and C++.

在使用Objective-C和c++时,文件扩展为.mm (Objective-C++)。

Secondly the library looks like it hasn't been compiled for armv7, so you will need to rebuild it for any architectures you want to support, which will be one or more of armv6, armv7, armv7s and i386 (for the iPhone Simulator).

其次,该库看起来还没有为armv7编译,因此您需要为希望支持的任何体系结构重新构建它,这将是一个或多个armv6、armv7、armv7s和i386(用于iPhone模拟器)。

If you are targeting iOS 5.0+ then that will be all of the above apart from armv6 which isn't supported on later versions of Xcode.

如果你的目标是ios5.0 +,那么这将会是除了armv6之外的所有内容,而这在Xcode的后续版本中是不受支持的。

Thirdly, make sure you use the same version of C++ and C++ library in both the library and the app, otherwise bad things will happen.

第三,确保在库和应用程序中使用了相同版本的c++和c++库,否则会发生不好的事情。

#3


0  

Make sure:

确保:

C++ Language Dialect Set "Compiler Default" instead of "GNU++11[-std=gnu++11]"

c++语言方言设置“编译器默认”而不是“GNU++11[-std= GNU++11]”

C++ Standard Library Set "Compiler Default" instead of "libc++(LLVM C++ standard library with C++11 support)"

c++标准库设置“编译器默认”而不是“libc++(LLVM c++标准库,c++ 11支持)”。

Also check:

也检查:

C Language Dialect Set "C00 [-std=c99]" instead of "GNU00 [-std=gnu99]"

C语言方言设置"C00 [-std=c99]"而不是"GNU00 [-std=gnu99]"

and tesseract files should be referenced properly. (drag and drop files not reference properly)

tesseract文件应该被正确引用。(拖放文件不能正确引用)

#4


0  

ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  1. Change Project -> Project -> Build Settings -> **"Enable Bitcode" to NO

    更改项目->项目->构建设置-> **“启用位码”为NO。

  2. also remove all linker flags in "linking" -> "Other Linker Flags" and add this

    还可以删除“链接”->“其他链接标记”中的所有链接标记,并添加这个。

在iOS应用中Tesseract集成中的错误。 3. After that install pods by command "pod install"

3所示。在安装后,通过命令“pod安装”

It's works for me on Swift 2 and Xcode 7.2 (beta)

在Swift 2和Xcode 7.2 (beta)中对我有用