Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zlib header not found when cross compiling with mingw?

I'm running ./configure --host=x86_64-w64-mingw32 but for some reason it tells me "zlib header not found.". I have the packages installed(apt-get install zlib1g-gev) but it still tells me this.

When I just run ./configure it compiles fine.

I'm trying to cross-compile a 64 bit executable for Windows on Debian 7 with MinGW-64

What must I do to fix this problem or avoid any thing like this?

like image 686
dominique120 Avatar asked Jan 11 '23 09:01

dominique120


1 Answers

Windows software requires windows libraries, Mingw is looking for cross-compiled Zlib, which you have to build yourself:

  1. Download zlib source
  2. Edit PREFIX value in win32/Makefile.gcc. For 32-bit build it will look like:

PREFIX = i686-w64-mingw32-

  1. Do not run configure! Use these two commands instead (find "i686-w64-mingw32" folder in your system and correct these paths if it's not in /usr):

BINARY_PATH=/usr/i686-w64-mingw32/bin INCLUDE_PATH=/usr/i686-w64-mingw32/include LIBRARY_PATH=/usr/i686-w64-mingw32/lib make -f win32/Makefile.gcc

BINARY_PATH=/usr/i686-w64-mingw32/bin INCLUDE_PATH=/usr/i686-w64-mingw32/include LIBRARY_PATH=/usr/i686-w64-mingw32/lib make -f win32/Makefile.gcc install

At this point you'll have the cross-compiled zlib accessible by Mingw tools. For x64 the PREFIX var (and paths) will contain this: x86_64-w64-mingw32 instead of i686-w64-mingw32.

The following link was really helpful: https://wiki.openttd.org/Cross-compiling_for_Windows#Compiling_zlib

like image 187
ogurets Avatar answered Feb 13 '23 04:02

ogurets