meh / ruby-tesseract-ocr

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

Compile Error #21

Closed ferbass closed 11 years ago

ferbass commented 11 years ago

I get an error when i use require "tesseract"

 require "tesseract"
CompilationError: compile error: see logs at /var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/3730aac9d43d40dd807d16ed2cc0881351a19cd2.log
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders/c.rb:114:in `shared_object'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:90:in `block in build'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `instance_eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/builders.rb:87:in `build'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:54:in `singleton_inline'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ffi-inline-0.0.4.3/lib/ffi/inline/inline.rb:39:in `inline'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:34:in `'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:31:in `'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract/c.rb:29:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:26:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract-ocr.rb:35:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:51:in `require'
    from /usr/local/rvm/gems/ruby-1.9.3-p448/gems/tesseract-ocr-0.1.5/lib/tesseract.rb:25:in `'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:116:in `require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:116:in `rescue in require'
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:122:in `require'
    from (irb):1
    from /usr/local/rvm/rubies/ruby-1.9.3-p448/bin/irb:16:in `
'1.9.3-p448 :002 >

looking on log file and i got

1 error generated.
g++ -dynamic -bundle -fPIC   -I/usr/local/Cellar/tesseract/3.02.02/include/tesseract -o /var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/3730aac9d43d40dd807d16ed2cc0881351a19cd2.dylib /var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/3730aac9d43d40dd807d16ed2cc0881351a19cd2.cpp -ltesseract 2>>/var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/3730aac9d43d40dd807d16ed2cc0881351a19cd2.log
/var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/3730aac9d43d40dd807d16ed2cc0881351a19cd2.cpp:1:10: fatal error: 'tesseract/strngs.h' file not found
#include 

based on error i'm missing the tesseract-ocr headers file, ok

I'm install tesseract via homebrew brew install tesseract, home brew install automatically leptonica.

i found this closed issue Error getting setup, you comment to export CFLAGS AND LDFLAGS to point tesseract libs and headers

I'm export like this

CFLAGS=-I/usr/local/Cellar/tesseract/3.02.02/include/tesseract
LDFLAGS=-L/usr/local/Cellar/tesseract/3.02.02/lib

but i got a same error, can you help me?

Thanks in advanced

meh commented 11 years ago

CFLAGS should point to include not include/tesseract, as you can see from the log it's trying to include tesseract/strngs.h and not just strngs.h, unless inside that tesseract dir over there there's another tesseract dir, it's not gonna work.

ferbass commented 11 years ago

Thank you, solved tesseract error but now i have

1 error generated.
g++ -dynamic -bundle -fPIC  -L/usr/local/Cellar/leptonica/1.69/include/  -o /var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/c9b2f3d5a2feb532c5f70e3496cfe6285256a16f.dylib /var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/c9b2f3d5a2feb532c5f70e3496cfe6285256a16f.cpp -llept 2>>/var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/c9b2f3d5a2feb532c5f70e3496cfe6285256a16f.log
/var/folders/fy/lwmk3kdj24q99jc9c07q6g6m0000gn/T/.ffi-inline-501/c9b2f3d5a2feb532c5f70e3496cfe6285256a16f.cpp:1:10: fatal error: 'leptonica/allheaders.h' file not found
#include 

should i point LDFLAGS to leptonica? i tried but have no effect

meh commented 11 years ago

You have to add it to the CFLAGS, the header paths go in CFLAGS with -I, the paths where the .dlybs are go in LDFLAGS with -L.

ferbass commented 11 years ago

now it's ok

thank you so much

meh commented 11 years ago

You're welcome :)