Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zlib in Qt - QtZlib not present

Tags:

c++

zlib

cmake

qt

qt5

I am using QuaZip library, which has zlib dependency. I want to compile my CMake managed application under Archlinux and Windows 7, in both I have Qt 5.3.0 installed.

On Linux:

I have read here "how to add zlib to an existing qt installation" that zlib is a native part of Qt installation. But in archlinux there is no such directory. Of cause I searched through all other Qt include directories including QtCore, but there was no sign of zlib. On the other hand system installation of zlib can be found on archlinux through FindZLIB.cmake module.

On Windows:

In the Windows installation of Qt there is QtZlib folder in Qt include directory, so it can be included. Nevertheless, compiler always complain that he cannot link zlib functions from library, error log here. I've also tried to set external zlib library manually through TARGET_LINK_LIBRARIES but with no success.

Have anybody experiance with linking Zlib under Qt5 using CMake ?

like image 377
Michal Avatar asked Jun 02 '14 08:06

Michal


People also ask

Is it possible to link zlib functions from Qt library?

In the Windows installation of Qt there is QtZlib folder in Qt include directory, so it can be included. Nevertheless, compiler always complain that he cannot link zlib functions from library, error log here.

What is zlib?

zlib is a general purpose data compression library. Optionally used in Qt Core and and development tools. Configure with -system-zlib to avoid. The sources can be found in tqtc-qt5/qtbase/src/3rdparty/zlib. Project Homepage, upstream version: 1.2.11 zlib License. This software is provided 'as-is', without any express or implied warranty.

How do I find zlib files on Arch Linux?

1) You should use your package manager on Archlinux and your own installation on Windows. Do not rely on the Qt third-party installation. It may be there today, but disappear at any certain moment when a new release comes out. 2) Also, you should use FindZLIB.cmake for finding zlib the following way in your CMakeLists.txt:

Can I use a zip file with qtgui?

But indeed, Qt uses zip internally for things like writing compressed data into a pdf as well as compressing the XML that goes into an ODF document. So QtGui at least links to the libs and if your linker is not too picky it will just work with only a header file. If you want to use .zip files, you can also take a look at Bugless Archive.


1 Answers

Qt's zlib is an internal implementation detail. You're not supposed to use it. You need to link your own copy of zlib, just as you would need to if you weren't using Qt at all.

like image 129
Kuba hasn't forgotten Monica Avatar answered Sep 30 '22 02:09

Kuba hasn't forgotten Monica