Ошибка компиляции гема tesseract-ocr с помощью ruby ​​ffi-inliner

Когда я пытаюсь запустить следующий код,

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

Я получаю ошибки ниже

$ 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>'

Упомянутый файл журнала содержит следующее:

$ 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

Мой Gemfile.lock содержит следующее:

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

Версия Тессеракта (по крайней мере, предоставленная Ubuntu) - 3.02.01-2

Как мне получить это для компиляции?

1 ответ

Решение

Оказывается, Tesseract изменил свои открытые API в версии 3.02 по сравнению с 3.01, поэтому метод ReadConfigFile принимает только один параметр. Обходной путь: удалите второй параметр в lib/tesseract/c/baseapi.rb:159 согласно https://github.com/cwalsh/ruby-tesseract-ocr/commit/58d5d17d8c98feaaceacf78ae7dec67ea8c4a963.

Мех вносит исправление, которое работает как для 3.01, так и для 3.02.

Обновление: исправлено в tesseract-ocr v0.1.5

Другие вопросы по тегам