Qt World Summit: Submit your Presentation

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



    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:
    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