开发者

Building zlib libz.a for 32 bit

I am trying to compile a 32-bit vers开发者_StackOverflowion (MinGW) of a program I wrote using zlib. Until now, I've never has to compile for 32-bit so the version of zlib I compiled from source (libz.a) is 64-bit. I tried to rerun the makefile in the zlib-1.2.5 directory but it only compiles a 64bit version of libz.a.

I can't seem to find an option to build 32-bit.

Does anyone know how to do this?

Thanks!

Jeffrey Kevin Pry


Checking the configure file, you can see some env.

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

CFLAGS=-m32 ./configure


It turns out I had to get the 32bit version of MinGW and compile it with that. I was using MinGW64.


Using CFLAGS=-32 won't do it for me, configure script still shouts out telling me to use win32/Makefile.gcc instead all the time.


The recent version of zlib is 1.2.11, so it should be minimal gap of difference up until today. Without any context on system, the following might be useful for other users facing this similar problem these days.

I cross compile on Linux (Ubuntu 18.04), and target 32-bit version of zlib to be produced. What I did is as follows.

  1. ./configure (this is just to let us have required file to building process, we will be using different Makefile though)
  2. Modify win32/Makefile.gcc for its PREFIX=i686-w64-mingw32- (for 64-bit you change it to PREFIX=x86_64-w64-mingw32-.
  3. make -fwin32/Makefile.gcc
  4. Install to your desire location via 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. Notice that you need to specify INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH. BINARY_PATH will contains result .dll file.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜