OCR tesseract gem for ruby​​ / rails - 如何安装?

时间:2022-07-23 09:00:15

The tesseract-ocr gem installed correctly (including dependencies). However when launching the rails server I get the following compile error. I have never received a compile error at this stage, so I would be grateful for any help.

tesseract-ocr gem正确安装(包括依赖项)。但是,在启动rails服务器时,我收到以下编译错误。我在这个阶段从未收到编译错误,所以我将不胜感激任何帮助。

server:brandlove n$ rails s
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/compilers/gcc.rb:29:in `compile': compile error: see logs at /var/folders/hm/6n4h3d1s49b_pxt2m51gr39c0000gn/T/.ffi-inline-501/793babd774d7ac74de2eb789882efa735f45b30b.log (CompilationError)
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/builders/c.rb:114:in `shared_object'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/builders.rb:90:in `block in build'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/builders.rb:87:in `instance_eval'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/builders.rb:87:in `build'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/inline.rb:54:in `singleton_inline'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/ffi-inline-0.0.4/lib/ffi/inline/inline.rb:39:in `inline'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:34:in `<module:C>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:31:in `<module:Tesseract>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:29:in `<top (required)>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `<top (required)>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `<top (required)>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
    from /Users/n/Desktop/brandlove/config/application.rb:7:in `<top (required)>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
    from /Users/n/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
server:brandlove n$ 

LOG FILE:

日志文件:

/var/folders/hm/6n4h3d1s49b_pxt2m51gr39c0000gn/T/.ffi-inline-501/793babd774d7ac74de2eb789882efa735f45b30b.cpp:1:30: error: tesseract/strngs.h: No such file or directory
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:51: error: expected constructor, destructor, or type conversion before ‘*’ token
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:57: error: variable or field ‘destroy_string’ declared void
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:57: error: ‘STRING’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:57: error: ‘value’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:63: error: ‘STRING’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:63: error: ‘value’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:63: error: expected ‘,’ or ‘;’ before ‘{’ token
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:69: error: ‘STRING’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:69: error: ‘value’ was not declared in this scope
/Users/n/.rvm/gems/ruby-1.9.3-p0/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:69: error: expected ‘,’ or ‘;’ before ‘{’ token

1 个解决方案

#1


5  

as far as i can see you use mac os... simplest way to solve any installation mistakes is clean install :) of tesseract and gem 'tesseract-ocr'

据我所知,你使用mac os ...解决任何安装错误的最简单方法是清洁安装:) tesseract和gem'tesseract-ocr'

it is pretty easy if you have homebrew installed

如果你安装了自制软件,这很容易

$ brew install tesseract

it will take some time and will install tesseract itself and all necessary libs

这需要一些时间,并将安装tesseract本身和所有必要的库

and after, of course

当然,之后

$ gem install 'tesseract-ocr'

(or $ bundle install if you added it to Gemfile)

(如果你将它添加到Gemfile,则为$ bundle install)

#1


5  

as far as i can see you use mac os... simplest way to solve any installation mistakes is clean install :) of tesseract and gem 'tesseract-ocr'

据我所知,你使用mac os ...解决任何安装错误的最简单方法是清洁安装:) tesseract和gem'tesseract-ocr'

it is pretty easy if you have homebrew installed

如果你安装了自制软件,这很容易

$ brew install tesseract

it will take some time and will install tesseract itself and all necessary libs

这需要一些时间,并将安装tesseract本身和所有必要的库

and after, of course

当然,之后

$ gem install 'tesseract-ocr'

(or $ bundle install if you added it to Gemfile)

(如果你将它添加到Gemfile,则为$ bundle install)