Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fresh build: tesseract not found using pkg-config #312

Closed
nschlia opened this issue Mar 4, 2018 · 17 comments
Closed

Fresh build: tesseract not found using pkg-config #312

nschlia opened this issue Mar 4, 2018 · 17 comments

Comments

@nschlia
Copy link

nschlia commented Mar 4, 2018

Started a fresh build, it stops with "ERROR: tesseract not found using pkg-config"

Updating to latest ffmpeg_git_with_fdk_aac_x26x_high_bitdepth_shared git version [origin/master]...
Already up to date.
fetched no code changes, not forcing reconfigure for that...
configuring ffmpeg_git_with_fdk_aac_x26x_high_bitdepth_shared (/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/win32/ffmpeg_git_with_fdk_aac_x26x_high_bitdepth_shared) as $ PKG_CONFIG_PATH=/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib/pkgconfig PATH=/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/bin:$PATH ./configure --arch=x86 --target-os=mingw32 --cross-prefix=/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32- --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=ffmpeg-windows-build-helpers --enable-gray --enable-version3 --disable-debug --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-w32threads  --enable-libtesseract --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libzimg --enable-libzvbi  --enable-nvenc --enable-nvdec --extra-cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-cflags=-DCACA_STATIC --enable-gpl --enable-avisynth --enable-frei0r --enable-filter=frei0r --enable-librubberband --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libmfx --enable-avresample --extra-cflags=-mtune=generic --extra-cflags=-O3 --enable-shared --disable-static --prefix=/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/win32/ffmpeg_git_with_fdk_aac_x26x_high_bitdepth_shared --enable-nonfree --enable-decklink --enable-libfdk-aac 
ERROR: tesseract not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

Command was:

./cross_compile_ffmpeg.sh --high-bitdepth=y --gcc-cpu-count=4 --disable-nonfree=n --sandbox-ok=y --compiler-flavors=multi --build-ffmpeg-static=n --build-ffmpeg-shared=y

This has been tried twice, with and without the "--gcc-cpu-count=4" parameter. Same result.

A quick solution was to remove "--enable-libtesseract" around line 1667, but there must be reason why it won't find it although ./sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib/pkgconfig/tesseract.pc is there.

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

This is my tesseract.pc file

tesseract.pc.tar.gz

@Reino17
Copy link
Contributor

Reino17 commented Mar 4, 2018

Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.

I'd be more interested to know what this one says.
And how does your 'lept.pc' look like? And please post this just as text between code brackets, instead of archiving the file!

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

My lept.pc

prefix=/home/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/leptonica

Name: leptonica
Description: An open source C library for efficient image processing and image analysis operations
Version: 1.75.3
Libs: -L${libdir} -llept
Libs.private: -L/home/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib -lz -L/home/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib -lpng16 -lz   -L/var/lib/jenkins/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib -ltiff -llzma -ljpeg -lz -L/home/jenkins/ffmpeg-windows-build-helpers_high-bitdepth/workspace/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib -lwebp
Cflags: -I${includedir}

To get you a config.log I'll have to run another build first. Next time I'll add the text. I attached the file because I wanted to keep the post short. No problem if you rather want the plain file.

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

Can't run the build now because SF seems down again. Will do ASAP.

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

Started a fresh build. Now it fails when creating leptonica.

  CCLD     convertfilestops.exe
  CCLD     convertformat.exe
  CCLD     convertsegfilestopdf.exe
/home/jenkins/ffmpeg-windows-build-helpers/workspace/sandbox/cross_compilers/mingw/-w64-i686/bin/././libhome//gcc/i686-w64-mingw32/7.1.0/../..home//.jenkins.//ffmpeg../-windowsi686--buildw64-mingw32/bin-helpers//workspaceld:/sandbox cannot/cross_compilers find/mingw --w64ljpeg
-i686/bin/.jenkinscollect2: error: ld returned 1 exit status
./lib//ffmpeg-windows-build-helpers/workspacegcc//sandboxi686/-cross_compilersw64/-mingwmingw32-/w647.1.0-/i686./.bin//....//.lib.//gcc./.i686/-i686w64--w64mingw32-mingw32//7.1.0bin//.ld.:/ .cannot. /.find. /-.ljpeg.
/collect2: error: ld returned 1 exit status
i686-w64-mingw32/bin/ld: cannot find -ljpeg
collect2: error: ld returned 1 exit status
Makefile:2530: die Regel für Ziel „convertfilestops.exe“ scheiterte
make[2]: *** [convertfilestops.exe] Fehler 1
make[2]: *** Es wird auf noch nicht beendete Prozesse gewartet...
Makefile:2534: die Regel für Ziel „convertformat.exe“ scheiterte
make[2]: *** [convertformat.exe] Fehler 1
Makefile:2526: die Regel für Ziel „convertfilestopdf.exe“ scheiterte
make[2]: *** [convertfilestopdf.exe] Fehler 1
/home/jenkins/ffmpeg-windows-build-helpers/workspace/sandbox/cross_compilers/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/7.1.0/../../../../i686-w64-mingw32/bin/ld: cannot find -ljpeg
collect2: error: ld returned 1 exit status
Makefile:2538: die Regel für Ziel „convertsegfilestopdf.exe“ scheiterte
make[2]: *** [convertsegfilestopdf.exe] Fehler 1
make[2]: Verzeichnis „/home/jenkins/ffmpeg-windows-build-helpers/workspace/sandbox/win32/leptonica_git/prog“ wird verlassen
Makefile:476: die Regel für Ziel „all-recursive“ scheiterte
make[1]: *** [all-recursive] Fehler 1
make[1]: Verzeichnis „/home/jenkins/ffmpeg-windows-build-helpers/workspace/sandbox/win32/leptonica_git“ wird verlassen
Makefile:385: die Regel für Ziel „all“ scheiterte
make: *** [all] Fehler 2

@Reino17
Copy link
Contributor

Reino17 commented Mar 4, 2018

A quick solution was to remove "--enable-libtesseract" around line 1667

Do you want to compile FFmpeg with LibTesseract at all? If not, then you can disable it all together:

--- cross_compile_ffmpeg.sh.bak	2018-03-04 17:45:06.406250000 +0100
+++ cross_compile_ffmpeg.sh	2018-03-04 17:47:42.609375000 +0100
@@ -1664,7 +1664,7 @@
       init_options+=" --disable-schannel"
       # Fix WinXP incompatibility by disabling Microsoft's Secure Channel, because Windows XP doesn't support TLS 1.1 and 1.2, but with GnuTLS or OpenSSL it does. The main reason I started this journey!
     fi
-    config_options="$init_options  --enable-libtesseract --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libzimg --enable-libzvbi  --enable-nvenc --enable-nvdec"
+    config_options="$init_options --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libzimg --enable-libzvbi  --enable-nvenc --enable-nvdec"
     # With the changes being made to 'configure' above and with '--pkg-config-flags=--static' there's no need anymore for '--extra-cflags=' and '--extra-libs='.
     if [[ ! -f configure.bak ]]; then # Changes being made to 'configure' are done with 'sed', because 'configure' gets updated a lot.
       sed -i "/enabled libtwolame/s/&&$/-DLIBTWOLAME_STATIC \&\& add_cppflags -DLIBTWOLAME_STATIC \&\&/;/enabled libmodplug/s/.*/& -DMODPLUG_STATIC \&\& add_cppflags -DMODPLUG_STATIC/;/enabled libcaca/s/.*/& -DCACA_STATIC \&\& add_cppflags -DCACA_STATIC/" configure # Add '-Dxxx_STATIC' to LibTwoLAME, LibModplug and Libcaca. FFmpeg should change this upstream, just like they did with libopenjpeg.
@@ -1861,7 +1861,6 @@
   build_libass # Needs freetype >= 9.10.3 (see https://bugs.launchpad.net/ubuntu/+source/freetype1/+bug/78573 o_O) and fribidi >= 0.19.0. Uses fontconfig >= 2.10.92, iconv and dlfcn.
   build_libxavs
   build_libxvid # FFmpeg now has native support, but libxvid still provides a better image.
-  build_libtesseract
   build_libvpx
   build_libx265
   build_libopenh264
  CCLD     convertsegfilestopdf.exe
/home/jenkins/ffmpeg-windows-build-helpers/workspace/sandbox/cross_compilers/mingw/-w64-i686/bin/././libhome//gcc/i686-w64-mingw32/7.1.0/../..home//.jenkins.//ffmpeg../-windowsi686--buildw64-mingw32/bin-helpers//workspaceld:/sandbox cannot/cross_compilers find/mingw --w64ljpeg
-i686/bin/.jenkinscollect2: error: ld returned 1 exit status
./lib//ffmpeg-windows-build-helpers/workspacegcc//sandboxi686/-cross_compilersw64/-mingwmingw32-/w647.1.0-/i686./.bin//....//.lib.//gcc./.i686/-i686w64--w64mingw32-mingw32//7.1.0bin//.ld.:/ .cannot. /.find. /-.ljpeg.
/collect2: error: ld returned 1 exit status
i686-w64-mingw32/bin/ld: cannot find -ljpeg

That's obviously because you haven't compiled LibJPEG at all.
I take it you've seen my comment here? Do you need these executables? If not, then try to build Leptonica with generic_configure "--disable-programs".

And I now see this:

build_libtiff() {
  generic_download_and_make_and_install ftp://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz
  sed -i.bak 's/-ltiff.*$/-ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/libtiff-4.pc # static deps
} 

build_libtesseract() {
  build_libleptonica
  build_libtiff # no disable configure option for this in tesseract? odd...
  do_git_checkout_and_make_install https://github.com/tesseract-ocr/tesseract.git
  sed -i.bak 's/-ltesseract.*$/-ltesseract -lstdc++ -lws2_32 -llept -ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/tesseract.pc # why does it needs winsock? LOL plus all of libtiff's <sigh>
}

I have no idea why Roger has messed around with the pkg-config files so much. He has even added -ljpeg while he hasn't added code to compile LibJPEG at all.

You know what? Could you remove the 'win32/tiff-4.0.9', 'win32/leptonica_git' and the 'win32/tesseract_git' map, apply the following and re-run:

--- cross_compile_ffmpeg.sh.bak	2018-03-04 17:45:06.406250000 +0100
+++ cross_compile_ffmpeg.sh	2018-03-04 18:28:25.718750000 +0100
@@ -628,21 +628,28 @@
 build_libleptonica() {
   do_git_checkout https://github.com/DanBloomberg/leptonica.git 
   cd leptonica_git
-    generic_configure "--without-libopenjpeg" # never could quite figure out how to get it to work with jp2 stuffs...I think OPJ_STATIC or something, see issue for tesseract
+    export PKG_CONFIG="pkg-config --static" # Automatically detect all Leptonica's dependencies.
+    generic_configure "--disable-programs --without-libopenjpeg" # never could quite figure out how to get it to work with jp2 stuffs...I think OPJ_STATIC or something, see issue for tesseract
     do_make_and_make_install
+    unset PKG_CONFIG
   cd ..
 }
 
 build_libtiff() {
   generic_download_and_make_and_install ftp://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz
-  sed -i.bak 's/-ltiff.*$/-ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/libtiff-4.pc # static deps
 } 
 
 build_libtesseract() {
-  build_libleptonica
   build_libtiff # no disable configure option for this in tesseract? odd...
-  do_git_checkout_and_make_install https://github.com/tesseract-ocr/tesseract.git
-  sed -i.bak 's/-ltesseract.*$/-ltesseract -lstdc++ -lws2_32 -llept -ltiff -llzma -ljpeg -lz/' $PKG_CONFIG_PATH/tesseract.pc # why does it needs winsock? LOL plus all of libtiff's <sigh>
+  build_libpng
+  build_libleptonica
+  do_git_checkout https://github.com/tesseract-ocr/tesseract.git
+  cd tesseract_git
+    if [[ ! -f tesseract.pc.in.bak ]]; then
+      sed -i.bak "s/-lpthread/-lpthread -lstdc++ -lws2_32/" tesseract.pc.in # why does it needs winsock? LOL
+    fi
+    generic_configure_make_install
+  cd ..
 }
 
 build_libzimg() {

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

I do not need OCR so I could remove libtesseract. I already did and was able to compile everything (both win32/64 and low/high bit depth).

Next I'll apply your patch and try again.

Normally I would build whatever the script does by default and only add whatever I specifically need. Or remove whatever hurts. :)

The problem with patches is that I use Jenkins and rebuild automatically whenever there's a change. When I patch the script I need to reapply the patches everytime changes arrive as they would get overwritten.

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

Applied the patch and started a new build. Unfortunately libvfilter fails:

libavfilter/af_aiir.c: In function 'expand':
libavfilter/af_aiir.c:396:39: error: 'FLT_EPSILON' undeclared (first use in this function); did you mean '__FLT_EPSILON__'?
         if (fabs(coeffs[2 * i + 1]) > FLT_EPSILON) {
                                       ^~~~~~~~~~~
                                       __FLT_EPSILON__
libavfilter/af_aiir.c:396:39: note: each undeclared identifier is reported only once for each function it appears in

@Reino17
Copy link
Contributor

Reino17 commented Mar 4, 2018

I have no idea where this is coming from. I don't understand how something totally unrelated to Tesseract like an audio filter could suddenly fail from this.

@nschlia
Copy link
Author

nschlia commented Mar 4, 2018

I also don't know either why libavfilter would fail. I replaced FLT_EPSILON with __FLT_EPSILON__ and it failed for other reasons. To make double sure I'll nuke the whole sandbox directory and really start from scratch including gcc tool chain to make double sure there are no remains of older builds.

@nschlia
Copy link
Author

nschlia commented Mar 5, 2018

In search for the reasons why this started I found that this may be because there was a symbolic link to the build directories. I created that quite a while ago (half a year or so) and it was never a problem. Havoc just started when Sourceforge developed problems and I did a "rm -Rf sandbox". All hell broke loose... I removed the link and put everything in a regular path. The theora problem #306 is still there, but maybe the above issues are gone. Build running...

@nschlia
Copy link
Author

nschlia commented Mar 5, 2018

Build complete, without the symbolic link, results:

  1. Build succeeds with your patches
  2. To double check I tried with the unpatched script: "ERROR: tesseract not found using pkg-config"

Conclusion: Your patches work.

@Reino17
Copy link
Contributor

Reino17 commented Mar 5, 2018

That's good to hear. Thanks.

@rdp
Copy link
Owner

rdp commented Mar 5, 2018 via email

@nschlia
Copy link
Author

nschlia commented Mar 5, 2018

config.log

Here's the "ffbuild/config.log" file.

@nschlia
Copy link
Author

nschlia commented Mar 6, 2018

Build OK after this fix: eafb30d

@nschlia
Copy link
Author

nschlia commented Mar 8, 2018

Clean build worked. Can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants