tesseract-ocr / tesstrain

Train Tesseract LSTM with make
Apache License 2.0
625 stars 180 forks source link

Unable to successfully process 'make leptonica tesseract' #183

Closed sawankumar94 closed 4 years ago

sawankumar94 commented 4 years ago

Hi, I cloned 'https://github.com/tesseract-ocr/tesstrain.git' at one of directory in desktop. I am using Ubuntu 20.04. I removed previously installed tesseract-ocr. I installed following libraries: g++ , autoconf, automake, libtool, pkg-config, libpng-dev, libjpeg8-dev, libtiff5-dev, zlib1g-dev, libicu-dev, libpango1.0-dev, libcairo2-dev, libleptonica-dev, ca-certificates from https://tesseract-ocr.github.io/tessdoc/Compiling and https://tesseract-ocr.github.io/tessdoc/Compiling-%E2%80%93-GitInstallation urls.

I tried doing 'make leptonica tesseract' on command line within 'tesstrain' directory. I have been getting this error make: ** [Makefile : 325: tesseract.built] Error 2 for long.

Please help.

Regards, Sawan

wrznr commented 4 years ago

Given the information you provide, we cannot help because we cannot identify the problem. At least, please provide the complete error message. Please, also consider to test whether your Tesseract installation actually works before you work with tesstrain.

sawankumar94 commented 4 years ago

Hi,

Thank you for your response . I am attaching two screenshots where i have highlighted error messages too. Screenshot from 2020-08-13 19-14-53 Screenshot from 2020-08-13 19-23-38

wrznr commented 4 years ago

This looks like a linking error. Very strange. I fear that you will have to redo the installation procedure from scratch and provide the complete command line output as a text file.

@stweil Have you ever encountered such linking errors when building tesseract/tesstrain?

rambalachandran commented 4 years ago

I'm having a similar issue when I try to run

make leptonica tesseract

This fails in the Makefile line 328 when trying to build tesseract

tesseract.built: tesseract-$(TESSERACT_VERSION)
    cd $< && \
        sh autogen.sh && \
        PKG_CONFIG_PATH="$(LOCAL)/lib/pkgconfig" \
            ./configure --prefix=$(LOCAL) && \
        LDFLAGS="-L$(LOCAL)/lib"\
            make -j$(CORES) install training-install && \
        date > "$@"

I have attached the entire stdout and stderr that I got when running the command tesstrain_std.txt

wrznr commented 4 years ago

@rambalachandran Do you encounter the same problem if you build tesseract outside of tesstrain?

@stweil Do the Tesseract versions shipping with Linux distros contain the training tools? I.e. could installing leptonica and Tesseract via the distro and skipping make leptonica tesseract circumvent the linking errors described above?

abandonware-magazines commented 4 years ago

I had the same issue:

Making all in unittest
make[3]: Entering directory '/home/owner/Workspace/tesstrain/tesseract-4.1.0/unittest'
mkdir -p tmp
make[3]: Leaving directory '/home/owner/Workspace/tesstrain/tesseract-4.1.0/unittest'
make[2]: Leaving directory '/home/owner/Workspace/tesstrain/tesseract-4.1.0'
make[1]: Leaving directory '/home/owner/Workspace/tesstrain/tesseract-4.1.0'
Makefile:328: recipe for target 'tesseract.built' failed
make: *** [tesseract.built] Error 2

I was able to resolve it by removing -j$(CORES) from the makefile command:

$ git diff Makefile
diff --git a/Makefile b/Makefile
index dd440a4..3d225cb 100644
--- a/Makefile
+++ b/Makefile
@@ -330,7 +330,7 @@ tesseract.built: tesseract-$(TESSERACT_VERSION)
                PKG_CONFIG_PATH="$(LOCAL)/lib/pkgconfig" \
                        ./configure --prefix=$(LOCAL) && \
                LDFLAGS="-L$(LOCAL)/lib"\
-                       make -j$(CORES) install training-install && \
+                       make install training-install && \
                date > "$@"
wrznr commented 4 years ago

That is interesting.

@stweil @kba Could you please confirm this defective behavior? Does this indicate a dependency in the build process of Tesseract which is not correctly resolved by the parallelization mechanism of make?

rambalachandran commented 4 years ago

I can also confirm that I followed @abandonware-magazines and removing -j$(CORES) fixed the makefile bug

stweil commented 4 years ago

Confirmed. And yes, that's a bug in the Makefiles of Tesseract 4.1.0 (and also 4.1.1, even latest git has this issue). make leptonica tesseract CORES=1 helps to work around that bug.

rambalachandran commented 4 years ago

Its best if you can change the README.md to help people savetime from this bug

stweil commented 4 years ago

It's even better to fix it, so people don't get a bug. I am already working on a fix.

stweil commented 4 years ago

Pull request #193 fixes this bug and updates the software versions. Maybe you can try it and confirm that it works for you, too.

stweil commented 4 years ago

The fix is merged now, so this issue can be closed. Please report if there remains a problem.