问题描述
我已经安装了一个tesseract-ocr(0.1.5)宝石。
也安装了依赖关系(tesseract / 3.04.00和leptonica / 1.72) p>
Mac OS X Yosemity。
当我执行 rake db:migrate
出现错误:
rake中止!
CompilationError:编译错误:请参阅/var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log中的日志
/Users/user/.rvm/gems/ruby-2.2 .2 @project / gems / ffi-inline-0.0.4.3 / lib / ffi / inline / compilers / gcc.rb:35:在`compile'中
/Users/user/.rvm/gems/ruby-2.2 .2 @project / gems / ffi-inline-0.0.4.3 / lib / ffi / inline / builders / c.rb:114:在`shared_object'中
/Users/user/.rvm/gems/ruby-2.2 .2 @project / gems / ffi-inline-0.0.4.3 / lib / ffi / inline / builders.rb:90:在`block in build'中
/Users/user/.rvm/gems/ruby-2.2 .2 @project / gems / ffi-inline-0.0.4.3 / lib / ffi / inline / builders.rb:87:在`instance_eval'
/Users/user/.rvm/gems/ruby-2.2.2 @ project / gems / ffi-inline-0.0.4.3 / lib / ffi / inline / builders.rb:87:在`build'
/Users/user/.rvm/gems/ruby-2.2.2@project /gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in`singleton_inline'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems /ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:in`inline'
/ Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:30:在< module:BaseAPI>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:27:in`< module:C> '
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in`< module :Tesseract>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in` < top(required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in`block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in`load_dependency'
/ Users / user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/depe ndencies.rb:274:在'require'中
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb: 83:在< top(required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb :274:'require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in`block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in`load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in`require'
/ Users / user / .rvm / gems / ruby-2.2.2 @project / gems / tesseract-ocr-0.1.5 / lib / tesseract / api.rb:26:在< top(required)>'
/ Users /user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in`require'
/Users/user/.rvm/ gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/acti ve_support / dependencies.rb:274:在`block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies中。 rb:240:在`load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in`需要'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in`< top(必需)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in`require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in`block(2 levels)in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in`each'
/ Users / user /.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:在`block in require'
/Users/user/.rvm /gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in`each'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in`require'
/ Users / user /。 rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler.rb:134:在'require'中
/Users/user/work/project/config/application.rb :17:在< top(required)>'
/ Users / user / work / project / Rakefile:4:在< top(required)>'
$ c
$ b $ p $ p $ g ++ -dynamic -bundle -fPIC -O /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.dylib /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.cpp -ltesseract 2>> /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log
/Users/user/.rvm/gems/ruby-2.2.2@project/gems /tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:171:10:错误:没有匹配的成员函数调用'SetImage'
API-> SetImage(PIX);
~~~~~ ^ ~~~~~~~
/usr/local/include/tesseract/baseapi.h:354:8:注意:候选函数不可行:第一个参数('const Pix *')会丢失const限定符
void SetImage(Pix * pix);
^
/usr/local/include/tesseract/baseapi.h:341:8注:候选函数不可行:需要5个参数,但提供了1个
void SetImage(const unsigned char * imagedata,int width,int height,
^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract /c/baseapi.rb:183:49:错误:无法使用类型为'STRING *'的$左元初始化'tesseract :: TessResultRenderer *'类型的参数
return api-> ProcessPages(filename,NULL, 0,output);
^ ~~~~~
/usr/local/include/tesseract/baseapi.h:542:63:注意:将参数传递给参数'renderer'在这里
int timeout_millisec,TessResultRenderer * renderer);
^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:189:65 :error:无法初始化类型为'STRING *'的左值类型为'tesseract :: TessResultRenderer *'的参数
return api-> ProcessPage(pix,page_index,filename,NULL,0,output);
^ ~~~~~
/usr/local/include/tesseract/baseapi.h:558:40:note:将参数传递给参数'renderer'
TessResultRenderer * renderer);
$
我该如何解决它?
更新:这不是重复的问题。它无法帮助
Tesseract开发者在版本3.0.4中改变了一些东西,tesseract-ocr gem失去了兼容性用它。我看到的最佳解决方案是现在降级。您可能在Mac上安装了以前版本的Tesseract,请使用 brew info tesseract
来查找。如果是这样,只需使用 brew switch
即可。我最近做了 brew cleanup
,因此我必须卸载tesseract并从旧公式安装它,如下所示:
$ brew卸载tesseract
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb
code>
这将安装Tesseract 3.02.02_3d,它似乎正在工作。
您可以在中找到更多信息并跟踪此问题。
I've installed a tesseract-ocr (0.1.5) gem.
Dependencies are also installed (tesseract/3.04.00 and leptonica/1.72)
Mac OS X Yosemity.
When I do rake db:migrate
an error appears:
rake aborted!
CompilationError: compile error: see logs at /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders/c.rb:114:in `shared_object'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:90:in `block in build'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `instance_eval'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `build'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in `singleton_inline'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:in `inline'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:30:in `<module:BaseAPI>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:27:in `<module:C>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in `<module:Tesseract>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:25:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:83:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:274:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `<top (required)>'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `each'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in `block in require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `each'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in `require'
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/bundler-1.10.6/lib/bundler.rb:134:in `require'
/Users/user/work/project/config/application.rb:17:in `<top (required)>'
/Users/user/work/project/Rakefile:4:in `<top (required)>'
In the log:
g++ -dynamic -bundle -fPIC -o /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.dylib /var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.cpp -ltesseract 2>>/var/folders/xg/g9n7qvns5z1gsr_yjh09n1nm0000gn/T/.ffi-inline-501/d2f8bb8a1867b800ff8ad69a3b850c91521b3760.log
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:171:10: error: no matching member function for call to 'SetImage'
api->SetImage(pix);
~~~~~^~~~~~~~
/usr/local/include/tesseract/baseapi.h:354:8: note: candidate function not viable: 1st argument ('const Pix *') would lose const qualifier
void SetImage(Pix* pix);
^
/usr/local/include/tesseract/baseapi.h:341:8: note: candidate function not viable: requires 5 arguments, but 1 was provided
void SetImage(const unsigned char* imagedata, int width, int height,
^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:183:49: error: cannot initialize a parameter of type 'tesseract::TessResultRenderer *' with an lvalue of type 'STRING *'
return api->ProcessPages(filename, NULL, 0, output);
^~~~~~
/usr/local/include/tesseract/baseapi.h:542:63: note: passing argument to parameter 'renderer' here
int timeout_millisec, TessResultRenderer* renderer);
^
/Users/user/.rvm/gems/ruby-2.2.2@project/gems/tesseract-ocr-0.1.5/lib/tesseract/c/baseapi.rb:189:65: error: cannot initialize a parameter of type 'tesseract::TessResultRenderer *' with an lvalue of type 'STRING *'
return api->ProcessPage(pix, page_index, filename, NULL, 0, output);
^~~~~~
/usr/local/include/tesseract/baseapi.h:558:40: note: passing argument to parameter 'renderer' here
TessResultRenderer* renderer);
^
How can I solve it?
Update: It's not duplicate question. It doesn't help Error setting up the tesseract OCR in gem in rails
Tesseract developers changed quite some stuff in version 3.0.4 and tesseract-ocr gem lost compatibility with it. The best solution I see is to downgrade for now. You may have previous versions of Tesseract installed on your mac, use brew info tesseract
to find that out. If so, just use brew switch
. I did brew cleanup
recently, so I had to uninstall tesseract and install it from the old formula, like so:
$ brew uninstall tesseract
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb
This will install Tesseract 3.02.02_3d that seems to be working.You can find more info and track this issue at tesseract-ocr repo.
这篇关于在mac os上的Tesseract-ocr gem问题x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!