tesseract-ocr / tesseract

Tesseract Open Source OCR Engine (main repository)
https://tesseract-ocr.github.io/
Apache License 2.0
62.33k stars 9.52k forks source link

Linker error for blamer.cpp when legacy code is disabled #2532

Closed Shreeshrii closed 5 years ago

Shreeshrii commented 5 years ago

libtool: link: ranlib .libs/libtesseract.a
libtool: link: rm -fr .libs/libtesseract.lax
libtool: link: ( cd ".libs" && rm -f "libtesseract.la" && ln -s "../libtesseract.la" "libtesseract.la" )
/bin/sh ../../libtool  --tag=CXX   --mode=link g++  -std=c++14 -std=c++14   -o tesseract tesseract-tesseractmain.o libtesseract.la -llept      -lrt -lpthread
libtool: link: g++ -std=c++14 -std=c++14 -o tesseract tesseract-tesseractmain.o  ./.libs/libtesseract.a -llept -lrt -lpthread
./.libs/libtesseract.a(blamer.o): In function `BlamerBundle::InitForSegSearch(WERD_CHOICE const*, MATRIX*, int, bool, STRING*, tesseract::LMPainPoints*, double, WERD_RES*)':
blamer.cpp:(.text+0x2aac): undefined reference to `tesseract::LMPainPoints::GeneratePainPoint(int, int, tesseract::LMPainPointsType, float, bool, float, WERD_RES*)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:594: tesseract] Error 1
make[2]: Leaving directory '/home/shreeshrii/tesseract/src/api'
make[1]: *** [Makefile:501: all-recursive] Error 1
make[1]: Leaving directory '/home/shreeshrii/tesseract'
make: *** [Makefile:410: all] Error 2
make  all-recursive

libtool: link: ranlib .libs/libtesseract.a
libtool: link: rm -fr .libs/libtesseract.lax
libtool: link: ( cd ".libs" && rm -f "libtesseract.la" && ln -s "../libtesseract.la" "libtesseract.la" )
/bin/sh ../../libtool  --tag=CXX   --mode=link g++  -std=c++14 -std=c++14   -o tesseract tesseract-tesseractmain.o libtesseract.la -llept      -lrt -lpthread
libtool: link: g++ -std=c++14 -std=c++14 -o tesseract tesseract-tesseractmain.o  ./.libs/libtesseract.a -llept -lrt -lpthread
./.libs/libtesseract.a(blamer.o): In function `BlamerBundle::InitForSegSearch(WERD_CHOICE const*, MATRIX*, int, bool, STRING*, tesseract::LMPainPoints*, double, WERD_RES*)':
blamer.cpp:(.text+0x2aac): undefined reference to `tesseract::LMPainPoints::GeneratePainPoint(int, int, tesseract::LMPainPointsType, float, bool, float, WERD_RES*)'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:594: tesseract] Error 1
make[2]: Leaving directory '/home/shreeshrii/tesseract/src/api'
make[1]: *** [Makefile:501: all-recursive] Error 1
make[1]: Leaving directory '/home/shreeshrii/tesseract'
make: *** [Makefile:410: all] Error 2
make  all-recursive
stweil commented 5 years ago

Did you try a clean build? I cannot reproduce this linker error.

Shreeshrii commented 5 years ago

It builds ok with c++17 on ppc64le

ubuntu@tesseract-ocr:~/tesseract$ tesseract -v
tesseract 5.0.0-alpha-213-g0ac59d
 leptonica-1.78.0
  libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.4.4 : libopenjp2 2.3.0
ubuntu@tesseract-ocr:~/tesseract$ uname -a
Linux tesseract-ocr 4.15.0-52-generic #56-Ubuntu SMP Tue Jun 4 22:53:08 UTC 2019 ppc64le ppc64le ppc64le GNU/Linux

It failed, even after make clean with c++14 on ppc64 with the current commit.

It built ok using an older commit.

[shreeshrii@rh-power-vm61 tesseract]$ uname -a
Linux rh-power-vm61.fit.vutbr.cz 4.16.3-301.fc28.ppc64 #1 SMP Mon Apr 23 21:44:46 UTC 2018 ppc64 ppc64 ppc64 GNU/Linux
[shreeshrii@rh-power-vm61 tesseract]$ tesseract -v
tesseract 5.0.0-alpha-161-gfad96d
 leptonica-1.76.0
  libgif 5.1.4 : libjpeg 6b (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 1.0.0

I will try to see if I can identify when it started failing.

stweil commented 5 years ago

I recently introduced new code using std::function and std::bind. Both should work with C++-11, but maybe there are differences to C++-17. I'll test that and look for a fix.

Shreeshrii commented 5 years ago

3871caae86e02c0f194bd334f4314dd59ac73c6a is the first bad commit commit 3871caae86e02c0f194bd334f4314dd59ac73c6a Date: Fri Jun 21 16:52:55 2019 +0200

Simplify indirect call of LMPainPoints::GeneratePainPoint
stweil commented 5 years ago

A C++-11 build with x86_64-linux-gnu-g++ has no such problems. C++-14 with sparc64-linux-gnu-g++ works, too. So does ppc64le-redhat-linux-g++.

Shreeshrii commented 5 years ago

The error is related to config options used. It builds ok with:

 ../configure  --enable-openmp --disable-debug --disable-opencl --disable-graphics --disable-shared 

It fails when --disable-legacy is used

../configure  --enable-openmp --disable-debug --disable-opencl --disable-graphics --disable-shared --disable-legacy
stweil commented 5 years ago

This should be fixed now. I removed the function which used the unresolved symbol from builds without legacy code.

Shreeshrii commented 5 years ago

Thanks!