Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Symbol not found: _clock_gettime on MacOs 10.11
dimitar last edited by
I build my app with on my MacOS 10.12 MacBook. I use the following directive in the build:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8
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: com.apple.main-thread 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/Splinter.app/Contents/MacOS/splinter 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/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -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/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -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/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -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
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.
@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.
dimitar last edited by