Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qmake and linking against Android zlib



  • Hi,

    What a statement I have to put in qmake to link against /system/libs/libz.so for any Android target?

    All compiles fine, #include <zlib.h> works out of the box without any additional INCLUDEPATH
    but linking fails.
    All Android docs say zlib is part of Android NDK.


  • Lifetime Qt Champion

    Hi,

    AFAIK

    LIBS += -lz
    

    should be enough if zlib is Androïd standard library.



  • Not that easy,
    LIBS += -lz doesn't work - still the same linking error.

    I found that library in the location:
    toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/30/
    of the NDK
    or actually, inside many locations with different numbers and architectures.
    Probably some -Lsomewhere has to prelude -lz



  • I found the solution:

    My project was already linked with zlib and probably all Qt Android projects are,
    so the statement LIBS += -lz is not necessary at all.

    I was trying to compile minizip library (part of zlib project) but Android doesn't support fopen64.
    The solution was to add USE_FILE32API to definitions to say minizip not to use that.
    Adding to my qmake: DEFINES += USE_FILE32API solved linking errors.


Log in to reply