Please nominate your Qt Champions for 2021!

Symbol not found: _clock_gettime on MacOs 10.11

  • Hi,

    I build my app with on my MacOS 10.12 MacBook. I use the following directive in the build:


    I expect that the resulting binary will be compatible with versions 10.8+. When I run it on MacOS 10.11 however, I get this crash:

    Crashed Thread:        0  Dispatch queue:
    Exception Type:        EXC_BREAKPOINT (SIGTRAP)
    Exception Codes:       0x0000000000000002, 0x0000000000000000
    Exception Note:        EXC_CORPSE_NOTIFY
    Dyld Error Message:
      Symbol not found: _clock_gettime
      Referenced from: /Applications/
      Expected in: /usr/lib/libSystem.B.dylib

    After doing some research, it looks like clock_gettime was added in 10.12 but doesn't exist in 10.11.

    Why didn't my build fail, having set my deployment target as 10.8?

    How can I ensure my binary is backwards compatible?

    Sample compilation output:

    /Applications/ -c -pipe -stdlib=libc++ -isysroot /Applications/ -mmacosx-version-min=10.8 -O2 -g -std=gnu++11 -Wall -W -fPIC -DRELEASE_BUILD -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG -DQT_NO_INFO_OUTPUT -DQT_NO_WARNING_OUTPUT -DBUILD_VERSION=4444 -DMINOR_VERSION=0 -DMAJOR_VERSION=1 -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../splinter -I. -I../includes/boost_1_55_0/include  -I/Applications/ -I/Users/dimitarz/Qt5.7.1/5.7/clang_64/lib/QtWidgets.framework/Headers -I/Users/dimitarz/Qt5.7.1/5.7/clang_64/lib/QtGui.framework/Headers -I/Users/dimitarz/Qt5.7.1/5.7/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/ -I/Applications/ -I. -I/Users/dimitarz/Qt5.7.1/5.7/clang_64/mkspecs/macx-clang -F/Users/dimitarz/Qt5.7.1/5.7/clang_64/lib -o main.o ../main.cpp

  • Lifetime Qt Champion


    The "easiest" solution would be to build your application with an older macOS SDK.

    To avoid this problem, creating a virtual machine with e.g. 10.9 and using the matching latest version of Xcode works pretty well.

    Not ideal, but currently nothing Qt can do anything about.

  • Moderators

    @dimitar Yea that pretty much comes down to knowing what things are added in which versions.

    The way I deal with this is to make sure I test in my lowest targeted environment and my highest. I get lazy and skip the middle ones.

    I tend to work on cutting edge so I get these types of issues a lot when I use old compilers or OSes. To get around it, just test on each environment and use the lowest common function that will work on all platforms.

    Funny thing is the last time I had an issue like this it was in using the new C++ clock functions that the older g++ didn't support. Clock stuff must have changed a lot recently, lol.

  • @SGaist @ambershark thank you for the answers, I suspected I'd have to test on the lower versions.

Log in to reply