Compilation problem for tesseract 4.00.00

1,589 views
Skip to first unread message

Kazi Moinul Hossain

unread,
Mar 15, 2017, 11:36:16 AM3/15/17
to tesseract-ocr
Hi everyone,

I have installed leptonica 1.74.1 and then tesseract 4.00.00.
After that, i have created a C++ program stated below which ultimately will show the leptonica and tesseract version installed in the system.

#include<baseapi.h>
#include<allheaders.h>
#include <sys/time.h>

int main() {

tesseract::TessBaseAPI *myOCR = new tesseract::TessBaseAPI();
printf("Tesseract-ocr version: %s\n",myOCR->Version());
printf("Leptonica version: %s\n",getLeptonicaVersion());
return 0;
}


While compiling my code using following command

$ g++ sample.cpp -o sample -I/usr/local/include/leptonica -I/usr/local/include/tesseract -llept -ltesseract

i am encountering following error,

//usr/local/lib/libtesseract.so: undefined reference to ‘pixReadFromMultipageTiff ‘
//usr/local/lib/libtesseract.so: undefined reference to ‘pixReadMemFromMultipageTiff ‘
collect2: error: Id returned 1 exit status

Again to mention, my tesseract version is 4.00.00 and leptonica version is 1.74.1.
Can anyone please help me to figure it out?

Thanks,
Kazi Moinul Hossain
Junior Software Developer

Zdenko Podobný

unread,
Mar 15, 2017, 1:59:19 PM3/15/17
to tesser...@googlegroups.com
It seems that your (leptonica?) installation is corrupted. Your example works for me (for 4.00 and 3.05):

zdeno@level2:~/test> g++ sample.cpp -o sample -llept -ltesseract
zdeno@level2:~/test> ./sample  
Tesseract-ocr version: 4.00.00alpha
Leptonica version: leptonica-1.74


Zdenko

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/be3b1def-f666-446a-ad16-211b4e3a8523%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kazi Moinul Hossain

unread,
Mar 16, 2017, 4:51:46 AM3/16/17
to tesseract-ocr
Should i reinstall leptonica & tesseract ?

Zdenko

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.

ShreeDevi Kumar

unread,
Mar 16, 2017, 4:56:52 AM3/16/17
to tesser...@googlegroups.com
You did not mention from where you installed leptonica and tesseract.

what info do you see when you type

tesseract -v


ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Kazi Moinul Hossain

unread,
Mar 16, 2017, 5:11:55 AM3/16/17
to tesseract-ocr
Tesseract installation source- https://github.com/tesseract-ocr/tesseract.git
Leptonica installation souce- https://github.com/DanBloomberg/leptonica.git

After typing tesseract -v, following information is being shown:
tesseract 4.00.00alpha-337-g7c27088
 leptonica-1.74.1
  libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8

 Found AVX
 Found SSE

ShreeDevi Kumar

unread,
Mar 16, 2017, 5:26:28 AM3/16/17
to tesser...@googlegroups.com

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Zdenko Podobný

unread,
Mar 16, 2017, 5:33:33 AM3/16/17
to tesser...@googlegroups.com
Try to ocr some image file. If it works than please povide output of
ldd tesseract


Zdenko

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Kazi Moinul Hossain

unread,
Mar 17, 2017, 6:37:55 AM3/17/17
to tesseract-ocr
While i am trying to ocr any image file by "tesseract image.tif image -l eng", i am encountered with another exception like "illegal instruction(core dumped)"
I don't understand where actually is the problem. For your better understanding, i am providing here with the installation commands below.
My system is ubuntu 16.04.

Installation commands:

1. sudo apt-get install autoconf automake libtool
2. sudo apt-get install autoconf-archive
3. sudo apt-get install pkg-config
4. sudo apt-get install libpng12-dev
5. sudo apt-get install libjpeg8-dev
6. sudo apt-get install libtiff5-dev
7. sudo apt-get install zlib1g-dev
8. sudo apt-get install libicu-dev
9. sudo apt-get install libpango1.0-dev
10. sudo apt-get install libcairo2-dev

Leptonica installation commands:

1. sudo apt-get install libleptonica-dev
2. sudo apt-get install xzgv
4. cd leptonica/
5. autoreconf -vi
6. ./autobuild
7. ./configure
8. ./make-for-local
9. ./make-for auto
10. sudo make
11. sudo make install
12. cd src/
14. tar -xvf xtractlib-1.5.tar.gz
15. sudo make allheaders
16. cd ../prog/
17. sudo make xtractprotos
18. cd ..
19. LD_LIBRARY_PATH = LD_LIBRARY_PATH:usr/local/lib
20. sudo ldconfig

Tesseract installation:

2. cd tesseract/
3. ./autogen.sh
4. ./configure --enable-debug
5. LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" make
6. sudo make install
7. sudo ldconfig
8. sudo make training
9. sudo make training-install


Zdenko

Kazi Moinul Hossain

unread,
Mar 17, 2017, 6:39:54 AM3/17/17
to tesseract-ocr
Can anyone please help me to figure out if there is any error in my installation commands and what will be the solution?


On Thursday, 16 March 2017 15:33:33 UTC+6, zdenop wrote:

Zdenko

Zdenko Podobný

unread,
Mar 17, 2017, 6:50:43 AM3/17/17
to tesser...@googlegroups.com
Do you understand what you did with this commnads?

Zdenko

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Kazi Moinul Hossain

unread,
Mar 17, 2017, 7:19:31 AM3/17/17
to tesseract-ocr
Not every commands though, but i understood the what i did with the commands. Is there any flaw in my commands?

Zdenko

ShreeDevi Kumar

unread,
Mar 17, 2017, 7:56:13 AM3/17/17
to tesser...@googlegroups.com
I use the following batch files in the folders where I have cloned tesseract and leptonica.

1. leptonica

#!/bin/bash
git pull origin
./autobuild
#./configure --disable-dependency-tracking 
./configure
make
sudo make install
sudo ldconfig
cd prog
make
cd ..

2. tesseract

#!/bin/bash
./autogen.sh
./configure 
LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include" make
sudo make install
sudo ldconfig
make training
sudo make training-install

ShreeDevi Kumar

unread,
Mar 17, 2017, 8:00:00 AM3/17/17
to tesser...@googlegroups.com
Your problem could be that you have some old version of leptonica installed on your system. Uninstall and remove all old versions and then try.

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

ShreeDevi Kumar

unread,
Mar 17, 2017, 8:03:25 AM3/17/17
to tesser...@googlegroups.com
Also you have not responded to zdenko's suggestion to provide output of 

ldd tesseract

or

ldd /usr/local/bin/tesseract


(use the location of tesseract, which you can find by

which tesseract)

Kazi Moinul Hossain

unread,
Mar 17, 2017, 8:03:33 AM3/17/17
to tesseract-ocr
Thanks a lot shree! Is there anything more you did in the "src" and "prog" directory under leptonica folder like "make allheaders", "make xtractprotos"?

ShreeDevi Kumar

unread,
Mar 17, 2017, 8:05:34 AM3/17/17
to tesser...@googlegroups.com
​>Is there anything more you did in the "src" and "prog" directory under leptonica folder like "make allheaders", "make xtractprotos"?

No.​

Kazi Moinul Hossain

unread,
Mar 17, 2017, 8:10:58 AM3/17/17
to tesseract-ocr
I am reinstalling leptonica and tesseract and I will let inform afterwards.

Kazi Moinul Hossain

unread,
Mar 17, 2017, 8:36:23 AM3/17/17
to tesseract-ocr
how can i uninstall old leptonica fully? I am attempting with "sudo apt-get autoremove leptonica" and it is showing "unable to locate package"


On Friday, 17 March 2017 17:56:13 UTC+6, shree wrote:

ShreeDevi Kumar

unread,
Mar 17, 2017, 9:40:00 AM3/17/17
to tesser...@googlegroups.com
try 

sudo apt-get remove libleptonica-dev

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

ShreeDevi Kumar

unread,
Mar 17, 2017, 9:41:20 AM3/17/17
to tesser...@googlegroups.com
sudo apt-get remove libleptonica-dev libleptonica

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

Message has been deleted

Kazi Moinul Hossain

unread,
Mar 20, 2017, 7:23:06 AM3/20/17
to tesseract-ocr
I uninstalled all the previous leptonica and tesseract, installed all the new stuffs. When i am typing tesseract -v, it is showing properly the leptonica and tesseract version. 
But When i am typing, tesseract sample.tif sample, it is showing "Illegeal instruction (core dumped)".
Ultimately, i became unable to compile the C++ program as mentioned here before.After compilation command, it is showing, "fatal error: baseapi.h: No such file or directory"
What could be the soultion? Please help
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

ShreeDevi Kumar

unread,
Mar 20, 2017, 7:30:17 AM3/20/17
to tesser...@googlegroups.com
you have not responded to zdenko's suggestion to provide output of 

ldd tesseract

or

ldd /usr/local/bin/tesseract


(use the location of tesseract, which you can find by

which tesseract)
ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Kazi Moinul Hossain

unread,
Mar 20, 2017, 7:40:16 AM3/20/17
to tesseract-ocr
After typing, ldd /usr/local/bin/tesseract, i got this,
linux-gate.so.1 =>  (0xb77d7000)
    libtesseract.so.4 => /usr/local/lib/libtesseract.so.4 (0xb72f4000)
    liblept.so.5 => /usr/local/lib/liblept.so.5 (0xb702c000)
    libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb6eb4000)
    libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb6e97000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6ce1000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb6cc4000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb6c6f000)
    libgomp.so.1 => /usr/lib/i386-linux-gnu/libgomp.so.1 (0xb6c4a000)
    libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb6c2f000)
    libpng12.so.0 => /lib/i386-linux-gnu/libpng12.so.0 (0xb6c04000)
    libjpeg.so.8 => /usr/lib/i386-linux-gnu/libjpeg.so.8 (0xb6ba5000)
    libtiff.so.5 => /usr/lib/i386-linux-gnu/libtiff.so.5 (0xb6b2a000)
    /lib/ld-linux.so.2 (0x800ba000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb6b24000)
    liblzma.so.5 => /lib/i386-linux-gnu/liblzma.so.5 (0xb6afe000)
    libjbig.so.0 => /usr/lib/i386-linux-gnu/libjbig.so.0 (0xb6aef000)

Zdenko Podobný

unread,
Mar 20, 2017, 7:58:13 AM3/20/17
to tesser...@googlegroups.com
On Mon, Mar 20, 2017 at 12:19 PM, Kazi Moinul Hossain <moinj...@gmail.com> wrote:
I uninstalled all the previous leptonica and tesseract, installed all the new stuffs. When i am typing tesseract -v, it is showing properly the leptonica and tesseract version. 
But When i am typing, tesseract sample.tif sample, it is showing "Illegeal instruction (core dumped)".
Ultimately, i became unable to compile the C++ program as mentioned here before.After compilation command, it is showing, "fatal error: baseapi.h: No such file or directory"
What could be the soultion? Please help

IMO there is only one solution if you want to start programming - take some course and learn something about your OS and programming - if you are not able to handle error  like "fatal error: baseapi.h: No such file or directory" by yourself, you are in troubles.

If are serious about programming you should also learn how to debug program e.g. find where (and maybe why) there is " illegal instruction(core dumped)".

Unless your tesseract installation is not working properly (at least with images in test folder) do not even think about trying your compile own program. There could be several reason for it, but you do not provide details, so it is no possibility to guide you.


On Friday, 17 March 2017 19:41:20 UTC+6, shree wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.

To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscribe@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at https://groups.google.com/group/tesseract-ocr.

Kazi Moinul Hossain

unread,
Mar 21, 2017, 7:34:27 AM3/21/17
to tesseract-ocr
Hi,
After long effort, i installed leptonica 1.74 and tesseract 4.00alpha. But here goes another problem.
When i am typing, "tesseract -v", i am getting the actual versions.

tesseract 4.00.00alpha
 leptonica-1.74

  libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8

 Found AVX
 Found SSE

but when i am compiling my following code,

#include "baseapi.h"

#include<allheaders.h>

int main(){
tesseract::TessBaseAPI *first=new tesseract::TessBaseAPI();
printf("Tesseract version %s\n",first->Version());
printf("leptonica version %s\n",getLeptonicaVersion());
return 0;
}

with the command,

g++ sample.c -o smpl.out -I/usr/local/include/leptonica -I/usr/local/include/tesseract -llept -ltesseract

i am getting the following output.

Tesseract version 3.04.01
leptonica version leptonica-1.74


Can anybody please help me to help me figure out this?
Message has been deleted

Kazi Moinul Hossain

unread,
Mar 21, 2017, 7:48:50 AM3/21/17
to tesseract-ocr
The code is

Kazi Moinul Hossain

unread,
Mar 21, 2017, 8:37:15 AM3/21/17
to tesseract-ocr
Finally, i solved it. Now after compilation, i am getting the correct version of leptonica and tesseract.
Tesseract version 4.00.00alpha
leptonica version leptonica-1.74


I uninstalled libleptonica-dev and libtesseract-dev and again compiled. It ran with correct output.
Thanks everyone in this group :)
Reply all
Reply to author
Forward
0 new messages