Compilation / Linking problem of tesseract 3.05.01 on Debian9

359 views
Skip to first unread message

Udo Abel

unread,
Nov 15, 2017, 6:36:49 AM11/15/17
to tesseract-ocr
I am trying to compile tesseract 3.05.01 on Debian9.
I have build and installed leptonica 1.74.04 from source.

The error is obviously about a missing library:

/bin/bash ../libtool  --tag=CXX   --mode=link g++  -g -O2 -std=c++11   -o tesseract tesseract-tesseractmain.o libtesseract.la  -lrt -lpthread 
libtool: link: g++ -g -O2 -std=c++11 -o .libs/tesseract tesseract-tesseractmain.o  ./.libs/libtesseract.so -lrt -lpthread
//usr/local/lib/liblept.so.5: error adding symbols: DSO missing from command line
/usr/bin/ld: tesseract-tesseractmain.o: undefined reference to symbol 'lept_free'
collect2: error: ld returned 1 exit status
Makefile:598: recipe for target 'tesseract' failed
make[2]: *** [tesseract] Error 1
make[2]: Leaving directory '/opt/tesseract-3.05.01/api'
Makefile:489: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/opt/tesseract-3.05.01'
Makefile:398: recipe for target 'all' failed
make: *** [all] Error 2
root@d:/opt/tesseract-3.05.01# 

I saw similiar issues reported, but all of them referred to a name conflict on liblept.so vs. libleptonica.so.
In my case, the library seemed to be in place:

root@d:# ls -lsa /usr/local/lib/
total 25196
    4 drwxrwsr-x  5 root staff     4096 Nov 15 11:21 .
    4 drwxrwsr-x 10 root staff     4096 Nov 14 12:34 ..
15816 -rw-r--r--  1 root staff 16192314 Nov 15 07:35 liblept.a
    4 -rwxr-xr-x  1 root staff      969 Nov 15 07:35 liblept.la
    0 lrwxrwxrwx  1 root staff       16 Nov 15 07:35 liblept.so -> liblept.so.5.0.1
    0 lrwxrwxrwx  1 root staff       16 Nov 15 07:35 liblept.so.5 -> liblept.so.5.0.1
 9356 -rwxr-xr-x  1 root staff  9578184 Nov 15 07:35 liblept.so.5.0.1
    4 drwxr-sr-x  2 root staff     4096 Nov 15 07:35 pkgconfig
    4 drwxrwsr-x  4 root staff     4096 Nov 14 13:45 python2.7
    4 drwxrwsr-x  3 root staff     4096 Nov 14 13:45 python3.5

libtesseract.la correctly refers to this libs:
...
# Libraries that this one depends upon.
dependency_libs=' -L/usr/local/lib /usr/local/lib/liblept.la -lz -lpng -ljpeg -ltiff -lpthread'


...
# The name that we can dlopen(3).
dlname='liblept.so.5'
...
# Directory that this library needs to be installed in:
libdir='/usr/local/lib'

And the liblept.so exports the required symbol:

root@d:/usr/local/lib# nm --defined-only -g liblept.so
...
00000000001ce260 T lept_fopen
00000000001ccda0 T lept_free
...

Make and install is done as root. I have no idea how to fix this and would be glad for any help.
A former build with the same steps in may this year went without problems.

Udo Abel

unread,
Nov 16, 2017, 3:14:17 AM11/16/17
to tesseract-ocr
After some testing I found that some symbols in the api/Makefile did not contain the expected contents:

root@d:/opt/tesseract-3.05.01/api# make testlept
testlept
libtesseract_la_LDFLAGS: -L/usr/local/lib -llept -version-info 3:5 -no-undefined
libtesseract_la_LINK: /bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -std=c++11 -L/usr/local/lib -llept -version-info 3:5 -no-undefined -o testlept
root@d:/opt/tesseract-3.05.01/api# 

libtesseract.la is empty. I'm not an expert in Makefile construction, so I don't know whether this is OK. Nevertheless I've added the libraries found in the libtesseract.la file to the command line arguments of tesseract$(EXEEXT): recipe. After that, I could build tesseract.

But I could not execute it, since it could not open its shared object file:

root@d:/usr/local/lib/pkgconfig# tesseract
tesseract: error while loading shared libraries: libtesseract.so.3: cannot open shared object file: No such file or directory

At that point I remembered that it might be necessary to run ldconfig. And after doing so:

root@d:/usr/local/lib/pkgconfig# ldconfig

I could start tesseract. It might be, that execution of ldconfig after building leptonica was all that had been necessary.


Reply all
Reply to author
Forward
0 new messages