3

When I try and run the following code,

require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)

I get the errors below

$ bundle exec ruby test.rb 
/home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/compilers/gcc.rb:19:in `compile': compile error: see logs at /tmp/.ffi-inliner-1000/69ee9294901b6113c67c891236ec7fc55128281d.log (CompilationError)
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders/c.rb:101:in `shared_object'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders.rb:80:in `block in build'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders.rb:77:in `instance_eval'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders.rb:77:in `build'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/inliner.rb:44:in `singleton_inline'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/inliner.rb:29:in `inline'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c/baseapi.rb:30:in `<module:BaseAPI>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c/baseapi.rb:27:in `<module:C>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c/baseapi.rb:25:in `<module:Tesseract>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c/baseapi.rb:25:in `<top (required)>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c.rb:83:in `require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/c.rb:83:in `<top (required)>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/api.rb:26:in `require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract/api.rb:26:in `<top (required)>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract-ocr.rb:35:in `require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/tesseract-ocr-0.1.3/lib/tesseract-ocr.rb:35:in `<top (required)>'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
    from /home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
    from test.rb:4:in `<main>'

The log file mentioned contains the following:

$ cat /tmp/.ffi-inliner-1000/69ee9294901b6113c67c891236ec7fc55128281d.log
/home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders/cpp.rb: In function ‘void read_config_file(tesseract::TessBaseAPI*, const char*, bool)’:
/home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders/cpp.rb:26:44: error: no matching function for call to ‘tesseract::TessBaseAPI::ReadConfigFile(const char*&, bool&)’
/home/cameron/.rvm/gems/ruby-1.9.3-p194/gems/ffi-inline-0.0.3/lib/ffi/inliner/builders/cpp.rb:26:44: note: candidate is:
/usr/include/tesseract/baseapi.h:242:8: note: void tesseract::TessBaseAPI::ReadConfigFile(const char*)
/usr/include/tesseract/baseapi.h:242:8: note:   candidate expects 1 argument, 2 provided

My Gemfile.lock contains the following:

GEM
  remote: https://rubygems.org/
  specs:
    call-me (0.0.2.2)
      refining
    ffi (1.0.11)
    ffi-extra (0.0.5)
      ffi
    ffi-inline (0.0.3)
      ffi (>= 0.4.0)
    iso-639 (0.0.3)
    refining (0.0.5.5)
    tesseract-ocr (0.1.3)
      call-me
      ffi-extra
      ffi-inline
      iso-639

PLATFORMS
  ruby

DEPENDENCIES
  tesseract-ocr

The tesseract version (at least, that provided by Ubuntu) is 3.02.01-2

How do I get this to compile?

4

1 回答 1

0

Turns out Tesseract changed their public api in v 3.02 compared to 3.01, so the ReadConfigFile method only takes one parameter. Workaround: delete the second parameter in lib/tesseract/c/baseapi.rb:159 as per https://github.com/cwalsh/ruby-tesseract-ocr/commit/58d5d17d8c98feaaceacf78ae7dec67ea8c4a963.

Meh is committing a fix that works for both 3.01 and 3.02.

Update: Fixed in tesseract-ocr v0.1.5

于 2012-04-29T08:50:18.867 回答