Important: Please read the Qt Code of Conduct -

Linking Error to lib on OSX

  • Hi,

    I am building Qt5.4 from source (gitorious) and I having a problem linking in my project. I have built from source successfully (I think) using
    @./configure -developer-build -opensource -nomake examples -nomake tests@
    This assumes -system-zlib evaluated to use system version

    The link error I get is
    @Undefined symbols for architecture x86_64:
    "_z_adler32", referenced from:
    QuaAdler32::calculate(QByteArray const&) in quaadler32.o
    QuaAdler32::reset() in quaadler32.o
    QuaAdler32::update(QByteArray const&) in quaadler32.o
    "_z_crc32", referenced from:
    QuaCrc32::calculate(QByteArray const&) in quacrc32.o
    QuaCrc32::reset() in quacrc32.o
    QuaCrc32::update(QByteArray const&) in quacrc32.o
    _unzReadCurrentFile in unzip.o
    _zipWriteInFileInZip in zip.o
    "_z_deflate", referenced from:
    _zipWriteInFileInZip in zip.o
    _zipCloseFileInZipRaw in zip.o
    "_z_deflateEnd", referenced from:
    _zipCloseFileInZipRaw in zip.o
    "z_deflateInit2", referenced from:
    _zipOpenNewFileInZip3 in zip.o
    "_z_get_crc_table", referenced from:
    _unzOpenCurrentFile3 in unzip.o
    _zipOpenNewFileInZip3 in zip.o
    "_z_inflate", referenced from:
    _unzReadCurrentFile in unzip.o
    "_z_inflateEnd", referenced from:
    _unzCloseCurrentFile in unzip.o
    "z_inflateInit2", referenced from:
    _unzOpenCurrentFile3 in unzip.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [debug/] Error 1
    20:38:41: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project qgroundcontrol (kit: Qt5.4 (source))
    When executing step "Make"
    20:38:41: Elapsed time: 02:31.@
    I have LIBS += -lz in the pro file, but it fails.

    Any help on how to fix this, or debug this would be awesome.

    NOTE: the code can be seen at and it builds ok when using Qt5.4 pre-built binaries.

  • Lifetime Qt Champion


    Looks like your are linking to a zlib not built for x86_64, are you sure you are using the right one ?

  • I'm building Qt from source on OSX 10.10 64 bit. I'm not electing the sib, but expecting Qt to pull the correct one. Are you suggesting I need to explicitly state 64bit on a 64bit system?

    The same code builds ok using prebuilt Qt on OSX 10.10 64bit. So I don't understand why it fails.

    Thanks for any pointers in right direction

  • Lifetime Qt Champion

    No, you don't need to.

    What are the options you gave to configure when building your own version of Qt ?

  • See the first post. It was on OSX 10.10.

  • Lifetime Qt Champion

    Can you show the linker line that fails ?

    Also, which version of Xcode are you using ?

  • Xcode 6.1. It's all latest versions for 10.10.

Log in to reply