Skip to content

Cross-Compiling Leptonica for Windows on Arch Linux #749

@Danny4021

Description

@Danny4021

Hello,

as stated in the title, I'm currently trying to cross-compile a Windows DLL for Leptonica on my Arch Linux System (Since our software needs to run on Windows and Linux) and I can't really get it to work.
I was trying to find anything inside the documentation about cross-compiling but I've not been able to find anything about it.
Here are the steps I took:

  • clone the Leptonica Repository git clone https://github.com/DanBloomberg/leptonica.git
  • Run the autogen.sh ./autogen.sh
  • Configure the mingw compiler like this ./configure --host=x86_64-w64-mingw32 --prefix=/home/leptonica/build --disable-static
  • Run make

After running these steps I get the following error:

jpegio.c:144:10: fatal error: jpeglib.h: No such file or directory
  144 | #include "jpeglib.h"
      |          ^~~~~~~~~~~
compilation terminated.

But that's not the main issue, since I can circumvent it by copying the necessary header files into the leptonica/src folder on my system (For some reason this error only occurs when trying to cross-compile. It doesn't happen when I don't configure the host when running ./configure)

After copying all the header files it's missing I get the following error after re-running make

Making all in prog
make[2]: Entering directory '/home/leptonica/prog'
  CCLD     convertfilestopdf.exe
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lpng16: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -ljpeg: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -ltiff: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lwebp: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lwebpmux: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lopenjp2: No such file or directory
/usr/lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld: cannot find -lz: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:2952: convertfilestopdf.exe] Error 1
make[2]: Leaving directory '/home/leptonica/prog'
make[1]: *** [Makefile:536: all-recursive] Error 1
make[1]: Leaving directory '/home/leptonica'
make: *** [Makefile:420: all] Error 2

Now to my questions:
Am I doing something fundamentally wrong?
Does anyone have recent experience cross-compiling leptonica for Windows or does someone have a tutorial on this matter? (I've been looking for a while but I haven't been able to find anything)
I'd just like to know if I'm on the right track or if I'm doing something very wrong.

Any kind of help on that matter would be much appreciated.
Thanks in advance!
Kind regards

(If this helps, here are the packages I've installed on arch in order to compile it):

mingw-w64-binutils 2.39-1
mingw-w64-crt 11.0.0-1
mingw-w64-environment 1-5
mingw-w64-gcc 13.1.0-1
mingw-w64-headers 11.0.0-1
mingw-w64-make 1-5
mingw-w64-winpthreads 11.0.0-1
libjpeg-turbo 3.0.2-2
libpng 1.6.43-1
libtiff 4.6.0-4
libtool 2.4.7+4+g1ec8fa28-7
lzlib 1.14-1
make 4.4.1-2
autoconf 2.72-1
automake 1.16.5-2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions