在导轨中设置gem中的tesseract OCR时出错 [英] Error setting up the tesseract OCR in gem in rails

查看:262
本文介绍了在导轨中设置gem中的tesseract OCR时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的rails环境中设置 tesseract-ocr gem。我已经运行了 brew install tesseract ,然后在应用程序上运行了一个bundle安装,并且所有运行都没有错误,但是在启动应用程序时( rails s )下面的错误是抛出:

  /Users/xxxx/.rvm/gems/ruby-1.9。 2-p290@xxxx/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:在`compile'中:compile error:see logs at / var / folders / 66 / pm_j0lp94gvcj0qnlcnsx9pw0000gn / T / .ffi-inline-501 / 4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log(CompilationError)

它引用以下日志文​​件:

  g ++ -dynamic -bundle -fPIC -L / usr / local / Cellar / tesseract / 3.02.02 / lib -I /usr/local/Cellar/tesseract/3.02.02/include -o /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.dylib /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi -inline-501 / 4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp -llept 2>> / var / folders / 66 / pm_j0lp94gvcj0qnlcnsx9pw 0000gn / T / .ffi-inline-501 / 4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log 
/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp:1:10:致命错误:'leptonica / allheaders.h'文件未找到
#include

我遵循了这两个问题:
https://github.com/meh/ruby-tesseract-ocr/issues/3 https://github.com/meh/ruby-tesseract-ocr/issues/21 p>

它讨论设置我所做的ENV变量。我在initalizers文件夹中创建了一个test.rb文件,其中包含以下变量集:

  ENV ['CFLAGS'] =' - I / usr / local / Cellar / tesseract / 3.02.02 / include'
ENV ['LDFLAGS'] ='-L / usr / local / Cellar / tesseract / 3.02.02 / lib'

然而,这对启动应用程序时的错误没有任何影响。



我不明白它是什么意思,当它说更新标题。我想知道是否有人能告诉我该怎么做,以得到这个工作。



谢谢。

解决方案

我已经解决了这个问题......



为了防止其他人遇到问题, / p>

首先必须同时运行:

brew安装tesseract



brew安装leptonica



然后在Gemfile中不是在初始化器中,你必须将两个作为环境变量的路径:

  ENV ['CFLAGS'] ='-I / usr / local / Cellar / tesseract /3.02.02/include -I / usr / local / Cellar / leptonica / 1.69 / include'
ENV ['LDFLAGS'] ='-L / usr / local / Cellar / tesseract / 3.02.02 / lib - L / usr / local / Cellar / leptonica / 1.69 / lib'


I'm trying to setup the tesseract-ocr gem in my rails environment. I have ran brew install tesseract and then ran a bundle install on the app and that all runs without errors however when starting the app (rails s) the following error is throw:

/Users/xxxx/.rvm/gems/ruby-1.9.2-p290@xxxx/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile': compile error: see logs at /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log (CompilationError)

It reference the following log file:

g++ -dynamic -bundle -fPIC  -L/usr/local/Cellar/tesseract/3.02.02/lib -I/usr/local/Cellar/tesseract/3.02.02/include -o /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.dylib /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp -llept 2>>/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log
/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp:1:10: fatal error: 'leptonica/allheaders.h' file not found
#include <leptonica/allheaders.h>

I followed these two issues: https://github.com/meh/ruby-tesseract-ocr/issues/3 and https://github.com/meh/ruby-tesseract-ocr/issues/21

It talks about setting ENV vars which i have done. I created a test.rb file in the initalizers folder with the following vars set:

ENV['CFLAGS'] = '-I/usr/local/Cellar/tesseract/3.02.02/include' 
ENV['LDFLAGS'] = '-L/usr/local/Cellar/tesseract/3.02.02/lib'

However this makes no difference to the error when starting the app.

I don't understand what it means when it says update the headers. I was wondering if someone could tell me exactly what to do to get this working.

Thanks.

解决方案

I've fixed this...

Just in case anyone else has a problem here's exactly how it was fixed in mine:

Firstly had to run both:

brew install tesseract

and

brew install leptonica

Then in the Gemfile NOT in an initializer you have to put both paths to the libraries as env vars:

ENV['CFLAGS'] = '-I/usr/local/Cellar/tesseract/3.02.02/include -I/usr/local/Cellar/leptonica/1.69/include' 
ENV['LDFLAGS'] = '-L/usr/local/Cellar/tesseract/3.02.02/lib -L/usr/local/Cellar/leptonica/1.69/lib'

这篇关于在导轨中设置gem中的tesseract OCR时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆