Important: Please read the Qt Code of Conduct -

[SOLVED] Attempting to port to Qt5; but a linker error on OSX

  • I'm trying to build a x86_64 application on MacOSX, using qmake/qt. I was able to compile in QT4, but not in QT5.

    Anyway, after running qmake to generate my makefiles etc:

    @qmake -recursive -spec macx-clang CONFIG+='release static'@

    Then when I run make, eventually I end up here:

    @/Applications/ -headerpad_max_install_names -arch x86_64 -Wl,-dead_strip -framework Cocoa -framework Carbon -Wl,-syslibroot,/Applications/ -mmacosx-version-min=10.6 -o [authors note: lots of .o files here] -L../lib -L../../debug -F/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/lib -lprotobuf -framework Security -framework SecurityInterface -framework ApplicationServices -framework CoreFoundation -lxml2 -lbz2 -lxar -framework ScriptingBridge -L/Users/seth/workspace/qt5.1.0//5.1.0/clang_64/plugins/iconengines -lssl -lcrypto -lz -lFLAC -framework Carbon -framework QtWebKitWidgets -framework QtQuick -framework QtQml -framework QtNetwork -framework QtCore -framework QtGui -framework QtOpenGL -framework QtWidgets -framework QtPrintSupport -framework Cocoa -framework QtWebKit -framework QtSql -framework QtSensors -framework QtSvg -framework QtXml -framework OpenGL -framework AGL@
    and then error...

    @ld: '_ZN3Log16DebugE7QStringS3' in debug/Log.o contains undefined reference for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)@

    I do not understand what 'undefined reference for architecture x86_64' means, and that's certainly the heart of the problem. Upon reading some other threads, some suggest that the libraries I'm linking against aren't x86_64, but after checking and rechecking, I can't find any non-x86_64 libraries involved in the process.

    All my .o files from the build are Mach-O 64-bit object x86_64 after checking with the file command.

    And for all libraries that I'm trying to reference (like libcrypto, for instance):

    Non-fat file: ../lib/libcrypto.a is architecture: x86_64

    And of course all the mac framework libraries are both 32/64bit capable.

    Does anyone have any suggestions on how I could debug this further?

  • Been fiddling all day, found it.

    The method that the link is complaining about has this in it:


    This method does not exist in qt5.

    (earlier in the file, I see this: extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);)

    if i comment these lines, the error goes away.

    So basically, a very bad compiler error for a missing symbol - because the compiler wasn't nice enough to point out what the actual problem is beyond the vague architecture statement; probably made worse because I'm building my application statically coupled with the extern.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    It's indeed a strange error.

    Since you're on OS X, you might be interested by the qtmacextras module, it will, on the long run, contain all the os x specific stuff.

    Since you found the solution, don't forget to update the thread's title to solved so other forum users will also know it.

    Happy coding :)

Log in to reply