zlib in Qt - QtZlib not present

前端 未结 3 1323
醉酒成梦
醉酒成梦 2020-12-10 21:00

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.

<
相关标签:
3条回答
  • 2020-12-10 21:33

    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.

    0 讨论(0)
  • 2020-12-10 21:45

    Try to add into pro file this line:

     INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib    
    

    or

    INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/qtbase/include/QtZlib
    

    or

     INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/qtbase/3rdparty/zlib   
    

    For my app this worked fine.

    0 讨论(0)
  • 2020-12-10 21:52

    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 讨论(0)
提交回复
热议问题