ruby-on-rails - 用于 ruby​​/rails 的 OCR tesseract gem - 如何安装?

标签 ruby-on-rails ruby rubygems ocr

正确安装了 tesseract-ocr gem(包括依赖项)。但是,当启动 rails server 时,出现以下编译错误。在此阶段我从未收到过编译错误,因此我将不胜感激。

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$ 

日志文件:

/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

最佳答案

据我所知,您使用的是 mac 操作系统... 解决任何安装错误的最简单方法是全新安装 :) tesseractgem 'tesseract-ocr'

如果你有 homebrew 就很容易了安装

$ brew install tesseract

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

当然还有之后

$ gem install 'tesseract-ocr'

(或 $ bundle install 如果您将其添加到 Gemfile)

关于ruby-on-rails - 用于 ruby​​/rails 的 OCR tesseract gem - 如何安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12808243/

相关文章:

ruby-on-rails - Rails heroku 无效配置选项

ruby-on-rails - SImplecov - Grape API 的测试覆盖率不正确

json - 用于更新 JSON 中的模型值的 Ruby 代码

ruby-on-rails - 同时将多个项目添加到购物车

ruby - rbenv gem 的 rdoc 在哪里?

ruby-on-rails - Json gem 安装失败。 Xcode 已经安装并且是最新的

ruby-on-rails - 如何通过 Ruby on Rails Web 应用程序执行控制台命令行并返回结果?

ruby-on-rails - RSpec 路由规范 POST 请求问题

ruby-on-rails - 如何保存用户注册日期[rails]

ruby-on-rails - 不会运行任何 Rails 命令