meh / ruby-tesseract-ocr

A Ruby wrapper library to the tesseract-ocr API.
629 stars 74 forks source link

" require 'tesseract' " results in CompilationError #14

Closed samnissen closed 11 years ago

samnissen commented 11 years ago

Total noob here, so maybe this is an issue on my side, but can't figure out how to get past this error. I'm hoping to install the gem on my Linux server running Centos 6. The upshot seems to be that -ltesseract should be in /usr/bin/ld, but isn't ...

I've read through the other compilation error issues posted, but I don't think I have any of those problems.

Error mesage

g++ -shared -fPIC    -o /tmp/.ffi-inline-0/3751549a49315e9a7703c6e20a39e587297ce8a8.so /tmp/.ffi-inline-0/3751549a49315e9a7703c6e20a39e587297ce8a8.cpp -ltesseract 2>>/tmp/.ffi-inline-0/3751549a49315e9a7703c6e20a39e587297ce8a8.log
/usr/bin/ld: cannot find -ltesseract
collect2: ld returned 1 exit status

Error in usage

[x@y ~]# irb
1.9.3-p327 :001 > require 'tesseract'
CompilationError: compile error: see logs at /tmp/.ffi-inline-0/3751549a49315e9a7703c6e20a39e587297ce8a8.log
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/compilers/gcc.rb:31:in `compile'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/builders/c.rb:114:in `shared_object'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/builders.rb:90:in `block in build'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/builders.rb:87:in `instance_eval'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/builders.rb:87:in `build'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/inline.rb:54:in `singleton_inline'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/ffi-inline-0.0.4.2/lib/ffi/inline/inline.rb:39:in `inline'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:34:in `<module:C>'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:31:in `<module:Tesseract>'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:29:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p327/gems/tesseract-ocr-0.1.5/lib/tesseract.rb:25:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from (irb):1
        from /usr/local/rvm/rubies/ruby-1.9.3-p327/bin/irb:13:in `<main>'1.9.3-p327 

Gem version

[x@y ~]# gem list

[...]

tesseract-ocr (0.1.5)

[...]

GCC version

[x@y ~]# gcc --version
gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)

[...]

OS

[x@y ~]# cat /etc/*release*
CentOS release 6.3 (Final)

Ruby version

[x@y ~]# ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

RVM Version (just in case it matters)

[x@y ~]# rvm -v
rvm 1.17.2 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
meh commented 11 years ago

Have you installed all the tesseract packages?

The gem depends on the installation of the tesseract library and its headers.

samnissen commented 11 years ago

I believe I have. I followed this guide: http://paramountideas.com/tesseract-ocr-30-and-leptonica-installation-centos-55-and-opensuse-113

Including:

yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel

and leptonica from http://www.leptonica.com/source/leptonlib-1.67.tar.gz

and the English language files from http://tesseract-ocr.googlecode.com/files/eng.traineddata.gz

meh commented 11 years ago

Well, the error says it can't find the library, so you should probably add LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" or the paths where the libraries and headers have been installed when running the script.

samnissen commented 11 years ago

Aha, so this is where my lack of knowledge betrays me (again). I ran the following, but truth be told I don't know what the paths should be, so I got the same error. So i guess first question is -- is what I did structurally correct? And, if so: How can I determine where the flags should point to? What am I looking to point them to?

export LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include"
./configure
make
make install

Your help is much appreciated!

meh commented 11 years ago

No, sorry I wasn't clear enough, you should export those env vars before running the Ruby script that requires the gem.