Tesseract OCR tuning error in gems in rails

I am trying to set up a tesseract-ocr gem in my rails environment. I ran brew install tesseract and then started installing the package in the application and everything works without errors, however, when I launch the application ( rails s ), the following error occurs:

 /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 refers to 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

He talks about setting up ENV vars, which I did. I created the test.rb file in the initalizers folder with the following sets:

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

However, this does not matter for an error when starting the application.

I don’t understand what this means when it comes to updating the headers. I was wondering if anyone could tell me what to do to make this work.

Thanks.

+2
source share
3 answers

I fixed it ...

Just in case, someone has a problem, how exactly this was fixed in mine:

First you had to run both:

brew install tesseract

and

brew install leptonica

Then, in the Gemfile NOT in the initializer, you must put both paths in 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' 
+2
source

Also there was the same error. I solved this by installing dev packages for tesseract and leptonica.

For debian based systems

sudo apt-get install libleptonica-dev libtesseract-dev

For base redhat systems

sudo yum insall leptonica-devel tesseract-devel

This solved the problem for me.

+4
source

This problem has (OS X El Capitan). Fixed by lowering tesseract with

 brew uninstall --force tesseract brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb 

and xcode update

 xcode-select --install 
+1
source

All Articles