Building zlib libz.a for 32 bit

I am trying to compile a 32-bit version (MinGW) of a program that I wrote using zlib. Until now, I have never had to compile for a 32-bit version, so the zlib version compiled from the source code (libz.a) is 64-bit. I tried to restart the makefile in the zlib-1.2.5 directory, but it only compiles the 64-bit version of libz.a.

It seems I can not find an option to build 32-bit.

Does anyone know how to do this?

Thanks!

Jeffrey Kevin Pry

+6
source share
3 answers

Turns out I needed to get a 32-bit version of MinGW and compile it with this. I used MinGW64.

0
source

Checking the configuration file, you can see some env.

On a 64-bit version of debian, the following command line will build a 32-bit version of libz

CFLAGS=-m32 ./configure 
+3
source

Using CFLAGS=-32 will not work for me, the configure script still screams that I constantly have to use win32/Makefile.gcc .


The latest version of zlib is 1.2.11, so the difference should be minimal to this day. Without any context in the system, the following may be useful for other users facing a similar problem these days.

I am cross-compiling on Linux (Ubuntu 18.04) and am aiming to create a 32-bit version of zlib. I did the following.

  1. ./configure (this is just so that we have the necessary file for the build process, although we will use a different Makefile)
  2. Change win32/Makefile.gcc for its PREFIX=i686-w64-mingw32- (for the 64-bit version, you change it to PREFIX=x86_64-w64-mingw32- .
  3. make -fwin32/Makefile.gcc
  4. Set make install -fwin32/Makefile.gcc SHARED_MODE=1 INCLUDE_PATH=/tmp/zlib-win32/include LIBRARY_PATH=/tmp/zlib-win32/lib BINARY_PATH=/tmp/zlib-win32/bin place using make install -fwin32/Makefile.gcc SHARED_MODE=1 INCLUDE_PATH=/tmp/zlib-win32/include LIBRARY_PATH=/tmp/zlib-win32/lib BINARY_PATH=/tmp/zlib-win32/bin . Note that you need to specify INCLUDE_PATH , LIBRARY_PATH and BINARY_PATH . BINARY_PATH will contain the result .dll file.
0
source

Source: https://habr.com/ru/post/891634/


All Articles