Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not open library #32

Open
movihus opened this issue Feb 21, 2014 · 15 comments
Open

Could not open library #32

movihus opened this issue Feb 21, 2014 · 15 comments

Comments

@movihus
Copy link

movihus commented Feb 21, 2014

I'm trying to deploy an application that uses tesseract-ocr with passenger and when I open the website I see this error:
Could not open library '/tmp/.ffi-inline-500/985899750dd2ded7660e51be030ff964c9d21dc8.so': libtesseract.so.3: cannot open shared object file: No such file or directory (LoadError)

I have installed:
tesseract 3.02.02
leptonica-1.70
libjpeg 6b : libpng 1.2.49 : libtiff 3.9.4 : zlib 1.2.3

What could I do?.
Thanks in advance.

@movihus
Copy link
Author

movihus commented Feb 21, 2014

I'm using rbenv 0.4.0-89-g14bc162 with ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux] on a CentOS release 6.4

@movihus
Copy link
Author

movihus commented Feb 21, 2014

I have run sudo ldconfig after installing tesseract but I get the same error

@meh
Copy link
Owner

meh commented Feb 24, 2014

Is the file actually present?

Is the LDPATH environment variable proper?

@movihus
Copy link
Author

movihus commented Feb 24, 2014

After a lot of work I could run the web app, but now I possibly discovered a bug.
I got this output when I want to use Tesseract::Engine

index >= 0 && index < size_used_:Error:Assert failed:in file ../ccutil/genericvector.h, line 512
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.5/lib/tesseract/api.rb:157: [BUG] Segmentation fault
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

All the trace here https://gist.github.com/movihus/226e7a4f49ff4fc6ad0e#file-gistfile1-txt

@meh
Copy link
Owner

meh commented Feb 24, 2014

What's the code that caused it?

@movihus
Copy link
Author

movihus commented Feb 24, 2014

I tried with this code:

path = 'image.jpg'
engine = Tesseract::Engine.new()
result = engine.text_for(path)

@meh
Copy link
Owner

meh commented Feb 24, 2014

Could you post the image as well please?

@movihus
Copy link
Author

movihus commented Feb 24, 2014

I tried with different images, for example this:
eurotext

@meh
Copy link
Owner

meh commented Feb 24, 2014

I pushed a new gem version since it works for me on master, can you try with this new version please?

@movihus
Copy link
Author

movihus commented Feb 24, 2014

I installed and now I have compilation errors:

g++ -shared -fPIC -o /tmp/.ffi-inline-500/f6b0bffaa19644042f282b7bf04377398eed387c.so /tmp/.ffi-inline-500/f6b0bffaa19644042f282b7bf04377398eed387c.cpp -ltesseract 2>>/tmp/.ffi-inline-500/f6b0bffaa19644042f282b7bf04377398eed387c.log
/tmp/.ffi-inline-500/f6b0bffaa19644042f282b7bf04377398eed387c.cpp:1:30: error: tesseract/strngs.h: No existe el fichero o el directorio
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:57: error: expected constructor, destructor, or type conversion before ‘*’ token
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:63: error: se declaró la variable o campo ‘destroy_string’ como void
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:63: error: ‘STRING’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:63: error: ‘value’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:69: error: ‘STRING’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:69: error: ‘value’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:69: error: expected ‘,’ or ‘;’ before ‘{’ token
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:75: error: ‘STRING’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:75: error: ‘value’ no se declaró en este ámbito
/home/deployer/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/tesseract-ocr-0.1.6/lib/tesseract/c.rb:75: error: expected ‘,’ or ‘;’ before ‘{’ token

I found this thread #7, but it supposses I installed the tesseract-devel package,
I use this method: https://github.com/grossws/tesseract-ocr-specs

yum list | grep tesseract*
tesseract.x86_64 3.02-1.el6 @/tesseract-3.02-1.el6.x86_64
tesseract-devel.x86_64 3.02-1.el6 @/tesseract-devel-3.02-1.el6.x86_64

yum list | grep leptonica*
leptonica.x86_64 1.69-1.el6 @/leptonica-1.69-1.el6.x86_64
leptonica-devel.x86_64 1.69-1.el6 @/leptonica-devel-1.69-1.el6.x86_64

@movihus
Copy link
Author

movihus commented Feb 24, 2014

I think I missed the issue, #3 is the correct

@movihus
Copy link
Author

movihus commented Feb 24, 2014

I found the headers in /home/makerpm/rpmbuild/BUILD/tesseract-ocr/ccutil/, copy it to /home/deployer/rpmbuild/BUILD/tesseract-ocr/ccutil/ (to have the correct permissions), modified my ~/.bashrc adding:

export CFLAGS=-I/home/deployer/rpmbuild/BUILD/tesseract-ocr/ccutil/

And the libs copied to /home/deployer/rpmbuild/BUILD/tesseract-ocr/api/.libs and then added to .bashrc

export LDFLAGS=-L/home/deployer/rpmbuild/BUILD/tesseract-ocr/api/.libs

But when I try to access the console througth rails console I get the same error.

What I'm doing wrong?.

@meh
Copy link
Owner

meh commented Feb 24, 2014

I don't know, I don't use the system you use.

@danielpclark
Copy link

For me compiling and installing the latest Leptonica http://leptonica.org/download.html fixed this. The apt-get repository version won't suffice.

@pgericson
Copy link

pgericson commented Jul 25, 2017

Solution for Redhat installation of leptonica and tesseract with the correct arguments to make it run

inspired from this .sh install file which did not work completely for me

yum -y update
yum -y install libstdc++ autoconf automake libtool autoconf-archive pkg-config gcc gcc-c++ make libjpeg-devel libpng-devel libtiff-devel zlib-devel

#Install AutoConf-Archive
wget ftp://mirror.switch.ch/pool/4/mirror/epel/7/ppc64/a/autoconf-archive-2016.09.16-1.el7.noarch.rpm
rpm -i autoconf-archive-2016.09.16-1.el7.noarch.rpm

# install leptonica from github
wget https://github.com/DanBloomberg/leptonica/archive/v1.72.tar.gz
tar -zxvf v1.72.tar.gz
cd leptonica-1.72
chmod +x configure # this is only if you have permission problems.
./configure --prefix=$HOME/local/
make
make install
cd ..

# install tesseract from github
wget https://github.com/tesseract-ocr/tesseract/archive/3.04.01.tar.gz
tar -zxvf 3.04.01.tar.gz
cd tesseract-3.04.01/
./autogen.sh
LIBLEPT_HEADERSDIR=$HOME/local/include ./configure --prefix=$HOME/local/ --with-extra-libraries=$HOME/local/lib
make
make install
LD_LIBRARY_PATH=#{home_dir}/local/lib CFLAGS=-I#{home_dir}/local/include LDFLAGS=-L#{home_dir}/local/lib bundle exec irb -r 'tesseract'
# you should see no errors

This will solve this issue and issue #3

I might be important to add $HOME/local/lib into /etc/ld.so.conf and run sudo ldconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants