MacOS Catalina app linked with GLFW3.3 crashes in Mojave

Hi All,

I am working on upgrading to glfw3 from glfw2 to better support retina displays. On the development machine (running Catalina), this all works fine. However, if I take the Catalina compiled binary to a Mojave machine, it crashes with some symbol not found. However, the symbol is coming from the glfwInit() call. Aside from trying to do a shared lib (Which I don’t want to since that itself has other cross platform compatibility issues), has anyone ran into similar issues?

P.S. I am setting the minimum-macosx-version flag of the Clang compiler to 10.11 when building my library, glfw3 is also built from source on the Catalina machine as static libs, without Vulkan.

Here’s the stack-trace when the crash happened:


Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x4] Symbol missing

Application Specific Information:
dyld2 mode

Dyld Error Message:
  Symbol not found: _objc_alloc_init
  Referenced from: /Volumes/VOLUME/*/KinTek_Explorer.app/Contents/MacOS/KinTek_Explorer_Py
  Expected in: /usr/lib/libobjc.A.dylib

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   dyld                          	0x00000001152fb456 __abort_with_payload + 10
1   dyld                          	0x00000001152fac4d abort_with_payload_wrapper_internal + 82
2   dyld                          	0x00000001152fac7f abort_with_payload + 9
3   dyld                          	0x00000001152b8aea dyld::halt(char const*) + 343
4   dyld                          	0x00000001152b8c17 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 170
5   libdyld.dylib                 	0x00007fff79e4ac1a dyld_stub_binder + 282
6   ???                           	0x000000010f0cd000 0 + 4547465216
7   KinTek_Explorer_Py            	0x000000010ec1ace6 glfwInit + 86
8   KinTek_Explorer_Py            	0x000000010e906cd7 zglfwInitialize() + 39
9   KinTek_Explorer_Py            	0x000000010e978c4b main + 539
10  libdyld.dylib                 	0x00007fff79e5eed9 start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000002000209  rbx: 0x0000000000000000  rcx: 0x00007ffee1402b88  rdx: 0x00007ffee1402ff0
  rdi: 0x0000000000000006  rsi: 0x0000000000000004  rbp: 0x00007ffee1402bd0  rsp: 0x00007ffee1402b88
   r8: 0x00007ffee1402bf0   r9: 0x0000000000000000  r10: 0x00000000000000e5  r11: 0x0000000000000246
  r12: 0x00000000000000e5  r13: 0x00007ffee1402ff0  r14: 0x0000000000000004  r15: 0x0000000000000006
  rip: 0x00000001152fb456  rfl: 0x0000000000000246  cr2: 0x0000000115369f40

Here’s the otool -L output on the app (aka ldd)

KinTek_Explorer_Py:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 23.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1675.129.0)
	/System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
	/System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
	/System/Library/Frameworks/CoreMIDI.framework/Versions/A/CoreMIDI (compatibility version 1.0.0, current version 69.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1894.40.150)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 52.0.0)
	/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1355.13.0)
	/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1069.22.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1675.129.0)

I found the underlying issue. It was a snafu on my part. I built glfw3 without specifying minimum-macosx-version so it defaulted to my platform, and glfw3 was linked against my application, so it didnt’ matter how i changed the deployment target in xcode, the glfw3 library was still only for macos 10.15. After setting the deployment target while building glfw3, the problem is now gone.

1 Like