m-ab-s / media-autobuild_suite

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.
GNU General Public License v3.0
1.56k stars 267 forks source link

ffmpeg - configure: tesseract not found using pkg-config #2161

Open LigH-de opened 2 years ago

LigH-de commented 2 years ago

I already removed local32/lib/pkgconfig/tesseract.pc to force reinstallation. Current content:

prefix=/local32
exec_prefix=${prefix}
bindir=/local32/bin-global
datarootdir = ${prefix}/share
datadir=/local32/bin-global
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: tesseract
Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
URL: https://github.com/tesseract-ocr/tesseract
Version: 5.1.0-20-gfacd5
Requires.private: lept libarchive iconv libtiff-4
Libs: -L${libdir} -ltesseract -LG:/MABS/msys64/mingw32/lib -larchive -lcrypto -lregex -lexpat -llzma -lzstd -llz4 -lb2 -lbz2 -lz -lbcrypt   
Libs.private: -lpthread  -lstdc++ -fopenmp -lgomp
Cflags: -I${includedir}

logs.zip

geo-y commented 2 years ago

64bit has the same issue:

logs.zip

After disabled rist and svthevc and tesseract in ffmpeg_options.txt, got build finished.

#--enable-librist
#--enable-libsvthevc
#--enable-libtesseract

current media-autobuild_suite.ini:

[compiler list] 
arch=3
license2=5
standalone=1
vpx2=2
aom=1
rav1e=1
dav1d=1
libavif=1
jpegxl=1
x2643=4
x2652=5
other265=1
svthevc=2
xvc=1
vvc=1
svtav1=2
svtvp9=1
flac=1
fdkaac=1
faac=2
exhale=1
mediainfo=1
soxB=1
ffmpegB2=4
ffmpegUpdate=1
ffmpegChoice=1
mp4box=1
rtmpdump=1
mplayer2=2
mpv=1
vlc=2
bmx=1
curl=4
ffmbc=2
cyanrip2=2
ripgrep=1
jq=1
jo=2
dssim=1
avs2=1
CC=1
cores=40
deleteSource=1
strip=1
pack=2
logging=1
updateSuite=1
timeStamp=1
ccache=2
noMintty=1

P.S. Added -lws2_32 in Libs: in tesseract.pc not working

ghost commented 2 years ago

I have the exact issue. But the solution would be to temporarily exclude tesseract from FFmpeg (my method worked (I swear it's now past the configure error)). image

ghost commented 2 years ago

In ffmpeg_options.txt, put a hashtag symbol before the configure key "--enable-libtesseract", like so: image

While Tesseract does do a little in FFmpeg (not only it's for capturing text from images), it can produce a compile error due to some bug in the script itself (for some reason, the FFmpeg configure can't detect that component using pkg-config (I guess))...

Biswa96 commented 2 years ago

Try to add -lws2_32 in Libs keyword in tesseract.pc file.

ghost commented 2 years ago

But will the suite think that this file's gone, and that it needs recompiling? If it isn't, then I'll try that.

Biswa96 commented 2 years ago

I was just guessing from the error logs. I assume if tesseract.pc is present tesseract project will not be rebuilt.

ghost commented 2 years ago

Is there a sort of "integrity" checks included in the suite?

Biswa96 commented 2 years ago

From a quick glance, I can not see any integrity check. Strictly speaking, git itself does the check for source files but not compiled/generated files.

LigH-de commented 2 years ago

I was just guessing from the error logs. I assume if tesseract.pc is present tesseract project will not be rebuilt.

As I wrote: I already removed tesseract.pc once to force rebuilding this, but it was not sufficient as its content will not have changed.

I may try that again if I can discover how to let the configuration add this parameter on its own during a forced rebuild. There may be a way to include it in the media-suite_compile.sh script...

Another way to force a rebuild would be removing local##/lib/libtesseract.[l]a or build/tesseract-git/ completely; but that may regenerate tesseract.pc without custom edits. It needs to be injected in its generation process.


PS: It will probably have to get added in this range, lines 552 ff.:

        sed -i -e 's|Libs.private.*|& -lstdc++|' \
               -e 's|Requires.private.*|& libarchive iconv libtiff-4|' tesseract.pc.in
        case $CC in
        *gcc) sed -i -e 's|Libs.private.*|& -fopenmp -lgomp|' tesseract.pc.in ;;
        *clang) sed -i -e 's|Libs.private.*|& -fopenmp=libomp|' tesseract.pc.in ;;
        esac

I am just not sure whether it should go to Libs: (requiring a new sed command) or would be allowed in Libs.private: as well (may just be included in an existing one).


PPS: No, I tried in two different ways, adding -lws2_32 did not change the reported error for me. The reason seems to be elsewhere.

waldonnis commented 2 years ago

Seems to be an issue with the latest libarchive version in msys2. Downgrading it and recompiling tesseract allowed the configure script test for libtesseract to succeed and ffmpeg to compile successfully.

I don't have time right now to dig into what changed in msys2 upstream and why (or how to fix it), but the pkgconfig file for libarchive went from this (old version, working): Libs.private: -lregex -lexpat -llzma -lzstd -llz4 -lb2 -lbz2 -lz -lbcrypt to this (new version, not working): Libs.private: -lcrypto -lregex -lexpat -llzma -lzstd -llz4 -lb2 -lbz2 -lz -lbcrypt

Seems like libcrypto got added to the list of lib dependencies without also adding libcrypto's dependencies. For reference, libcrypto's pkgconfig: Libs.private: -lws2_32 -lgdi32 -lcrypt32

You might be able to add the additional libs to libarchive's pkgconfig instead of downgrading as a temp workaround, but I haven't tested to see if that works.

Biswa96 commented 2 years ago

Seems like libcrypto got added to the list of lib dependencies without also adding libcrypto's dependencies

It was added for this issue https://github.com/msys2/MINGW-packages/issues/11157. Programs are compiled here statically. Libs.private should mention the libraries instead of linker flags. I can try to discuss that in msys2.

waldonnis commented 2 years ago

Libs.private should mention the libraries instead of linker flags. I can try to discuss that in msys2.

I thought that was the purpose of Requires.private, no? Isn't Libs.private correct for linker flags? It's been ages since I had to deal with this kind of stuff, though, so I'm probably wrong, but just curious. Either way, thanks for following up on this.

Biswa96 commented 2 years ago

I thought that was the purpose of Requires.private, no?

Opps, you're right. I shall try to discuss this with upstream.

Biswa96 commented 2 years ago

Can anyone verify if adding the following line in libarchive.pc file fixes this issue?

Requires.private: iconv libssl libcrypto
LigH-de commented 2 years ago

Going to test, but will take a while, MSYS2 just has new updates... Oh, wait. MABS is not building libarchive.

Biswa96 commented 2 years ago

Oh, wait. MABS is not building libarchive.

It is not required to build libarchive for this test. When you hit the tesseract error before compiling ffmpeg just add that line in libarchive.pc. Then rerun the MABS build as usual.

LigH-de commented 2 years ago

This would then be in /msys64/mingw##/lib/pkgconfig/ ... OK, testing.


Yes, configuring ffmpeg finished this way.

waldonnis commented 2 years ago

Yes, configuring ffmpeg finished this way.

Worked for me as well. I rebuilt tesseract as well and see a more exhaustive list of linker flags in its newly generated tesseract.pc pkgconfig file, so the additional requirements are definitely propagating to dependent projects. For reference: Old: Libs: -L${libdir} -ltesseract -L<omitted local path> -larchive -lregex -lexpat -llzma -lzstd -llz4 -lb2 -lbz2 -lz -lbcrypt New: Libs: -L${libdir} -ltesseract -L<omitted local path> -larchive -lcrypto -lregex -lexpat -llzma -lzstd -llz4 -lb2 -lbz2 -lz -lbcrypt -L<omitted local path> -liconv -lssl -L<omitted local path> -lcrypto -lws2_32 -lgdi32 -lcrypt32

Biswa96 commented 2 years ago

Patch sent in upstream https://github.com/libarchive/libarchive/pull/1723

1480c1 commented 2 years ago

@Biswa96 could we include that commit inside the MINGW-package for libarchive?