quazip icon indicating copy to clipboard operation
quazip copied to clipboard

Using Qt5Zlib to build on Windows

Open theMadStork opened this issue 3 years ago • 10 comments

Building using MSVC2017-32 bit cannot find Zlib on Qt 5.14.2. zlib has been in Qt for a while but I'm guessing the module that can be used to build quazip may only be available in Qt > 5.15

theMadStork avatar Apr 22 '21 19:04 theMadStork

I installed Qt 5.15.2 (there is now a Qt5Zlib folder) and cleared the quazip build directory and built with MSVC2019 32-bit and received the same message:

Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11")

I'm trying to build the release version of quazip 1.1

theMadStork avatar Apr 23 '21 02:04 theMadStork

Well, it won't work with 1.1, as the appropriate PR was merged after this release. Try with the master, and if it works, I'll make a new release shortly.

stachenov avatar Apr 23 '21 09:04 stachenov

using master it finds it now but there is a linking issue (many non-defined externals). I also get this warning:

C:\Qt\5.15.2\msvc2019\lib\Qt5Core.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64' [C:\Qt\addons_source\quazip\build\quazip\QuaZip.vcxproj]

This is the same issue I was having when try to compile my own zlib as well. I tried configuring the qt command prompt on windows for vcvarsall.bat amd64_x86 and vcvars32.bat but both had the same issue

theMadStork avatar Apr 23 '21 14:04 theMadStork

Damn, not this x86-vs-x64 stuff again.

The only easy way of dealing with it I know of is to ensure that everything has the same architecture: the installed Qt version, all libraries you use, the compiler, everything.

In your case it looks like you've installed a 32-bit version of Qt and try to compile for 64 bit (why? MSVC 64 bit installed or what?).

stachenov avatar Apr 23 '21 15:04 stachenov

I selected x86 environment by opening the command prompt for Qt 5.15.2 MSVC 2019 32-bit then vcvarsall.bat amd64_x86 or vcvars32.bat and finally removed all 64-bit msvc from qt but cmake still makes the target architecture x64. I don't know enough about make files to force it to 32-bit but that seems to be the issue.

When I build projects with QtCreator I can select 32 or 64 bit but cmake seems to use my systems architecture, which is x64. is there a way to force it to 32-bit?

theMadStork avatar Apr 23 '21 17:04 theMadStork

I always seem to have problems with this.

In my case it builds a 64-bit library successfully. Any reason why you want to build a 32-bit version? Seems like 64 bit systems are ubiquitous nowadays and support for 32 bit is dropping. Do you need to support legacy code or what?

stachenov avatar Apr 23 '21 19:04 stachenov

@theMadStork Have you tried adding -A Win32 to cmake command line?

cen1 avatar Apr 23 '21 20:04 cen1

Yes! I was trying to use CMAKE_GENERATOR to select the right platform compiler and wasn't having any luck but that's all I needed. One last note, to include in my project in QtCreator for Qt 5.15.2 I had to replace all #include <zlib.h> with #include <QtZlib/zlib.h>

Thanks for all your help

theMadStork avatar Apr 24 '21 13:04 theMadStork

Replacing zlib.h with QtZlib/zlib.h doesn't sound portable. I'd rather try to add an include path with zlib.h.

stachenov avatar Apr 24 '21 14:04 stachenov

Makes sense

theMadStork avatar Apr 24 '21 15:04 theMadStork

32bit builds are now added in CI and documented in main readme.

cen1 avatar Mar 10 '24 20:03 cen1