I'm desperately trying to compile Tesseract-ocr (4.0) on a Windows Machine with some restrictions.
- We are doing multi-platforms : an automated compilation must be possible (command-line)
- We are using specific 3rd party libraries : the compilation must accept custom path / libraries for most of its dependencies
- We are already using most of the 3rd party libraries for other part of the code : the compilation must not recompile them (thus, no cppan)
- Leptonica has been built with our special 3rdparty (ZLib, LibPng ..)
- Our project must "include" tesseract alongside theses specific 3rdparty
Problem :
I have strong issue specifying custom paths for Tesseract. Under Unix (CentOS, Ubuntu 16/18, Debian 8/9 ..), I was able to achieve my goal with the tools autogen autoconf autoheaders pkg-config.
Under Windows, autoconf-archive and pkg-config are unavailable (from what I tried) ; rendering autoconf unusable. I was neither able to compile using CMake and specifying a custom path for Leptonica (even after writing a new pkgconfig for leptonica).
Things I tried :
- Using MinGW and autoconf
- Manually installing pkg-config
- Cheating with autoconf-archive .m4 into aclocal
- Creating a VisualStudio project with cppan and modify it
- Various ways of telling CMake to search elsewhere for 3rdparty
Things that work on Linux :
- Autoconf with modified PKGConfig for custom compiled Leptonica (--with-extra-libraries PKG_CONFIG_PATH CPPFLAGS LDFLAGS)
Things I have not tried :
- Installing Leptonica on the machine (Not the point here)
- Rewriting CMakeFiles
- Unknown solutions ?
Possible Solutions
- MinGW (Windows) with pkg-config autoconf-archive
- Unknown way to tell CMake Leptonica custom path
- VisualStudio project without cppan
- Yours ?
Thank your for your interest.
EDIT 1
By trying various ways of manually installing pkg-config, Autoconf seemed to be unaware of its presence. This error was about pkg-config missing package (How to install pkg config in windows?).
CPPAN was deeply part of the visual studio project and I couldn't see how I could separate them.
I usually tell configure to look for leptonica package with the arguments --with-extra-libraries and PKG_CONFIG_PATH. CMake however, uses the "macro" find_package(Leptonica $PATH CONFIG REQUIRED). By looking at it a little bit, I was (maybe) able to specify its path with CMAKE_PREFIX_PATH, CMAKE_MODULE_PATH, Leptonica_DIR. The compilation was still unsuccessfull due to missing config files (LeptonicaConfig.cmake or leptonica-config.cmake).
I pointed theses variables to various folders of the leptonica folder after building it. For information, I built Leptonica with its configure as such :
bash configure --enable-shared=false --without-giflib --without-libwebp --without-libopenjpeg LDFLAGS="-LPATH/TO/ZLIB -LPATH/TO/LIBPNG .." CPPFLAGS="-IPATH/TO/ZLIB/INCLUDE ..."
I, however, was unable to locate theses files (while seeing a LeptonicaConfig.cmake.in under LeptonicaDir/cmake/template)
I hope I answered your questions. Please tell me if you need further details.