Statically link tesseract to a shared object

40 views
Skip to first unread message

Kıvanç Güçkıran

unread,
Nov 24, 2017, 10:13:51 AM11/24/17
to tesseract-ocr

Hello everyone,


I'm on Linux, using Tesseract 3.05.01, Leptonica 1.74.4. Building both from source. I have built them with no problem.

What I want to achieve is, statically link leptonica and tesseract to a shared object, which uses the functions from tesseract's API. Following this linkage, I wanted to link this shared object to an executable. Finally, there should be an executable with a shared object and these should not need any other shared object.

I've successfully linked the libraries to shared object(I thought so) but when I try to link to the executable, I see that Leptonica functions are not linked. What am I doing wrong?

The linking of the shared object:


g++ -I. -I/usr/local/include/tesseract -I/usr/local/include/leptonica -std=gnu++11 wrap.cpp  /usr/local/lib/liblept.a /usr/local/lib/libtesseract.a -shared -o wrap.so -fPIC -Wl,-Bsymbolic


Linking of the executable:


gcc test.c -o test wrap.so


The error I receive:


wrap.so: undefined reference to `sem_init' wrap.so: undefined reference to `pixExpandReplicate' wrap.so: undefined reference to `pixConvertTo8' wrap.so: undefined reference to `pixGetWpl' ... ... wrap.so: undefined reference to `pixConvertTo32' wrap.so: undefined reference to `pixaCreate' wrap.so: undefined reference to `sem_wait' collect2: error: ld returned 1 exit status
 

What should I do to overcome these linkage problems?


I've attached the wrap.cpp, wrap.h and test.c:

Code.zip


Environment

  • Tesseract Version: 3.05.01
  • Commit Number: The 3.05.01 branch, no change to the source
  • Platform: 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Code.zip

Mobeen Ali

unread,
Sep 9, 2020, 9:23:06 AM9/9/20
to tesseract-ocr
Hi!
did you found any solution for this?

Reply all
Reply to author
Forward
0 new messages