6

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 ?

0

2 Answers 2

12

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.

3
  • Thank you, this was a right solution for me. However, include path in quazip have to be rewritten in order to not use system/qt zlib includes.
    – Michal
    Jun 4, 2014 at 6:52
  • @Michal: not quite sure what you are referring to. Quazip upstream is just fine in that regard... Jun 4, 2014 at 7:28
  • yes, but quazip uses include "zlib.h" in its files which points to system installation of zlib at default, instead to my copy of zlib distributed together with project.
    – Michal
    Jun 4, 2014 at 7:31
1

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.

This is what I would suggest you doing on your Archlinux box:

pacman -S zlib

2) Also, you should use FindZLIB.cmake for finding zlib the following way in your CMakeLists.txt:

find_package( ZLIB REQUIRED )
if ( ZLIB_FOUND )
    include_directories( ${ZLIB_INCLUDE_DIRS} )
    target_link_libraries( YourProject ${ZLIB_LIBRARIES} )
endif( ZLIB_FOUND )
0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.