SDL2 linking errors on macOS

Hi. I’m developing a cross-platform app using CMake and vcpkg. SDL2 is compiled by vcpkg and then is added to the project like this:

find_package(SDL2 REQUIRED) # provided by vcpkg
target_include_directories(${TARGET} PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(${TARGET} PRIVATE ${SDL2_LIBRARIES})

This works fine both on Windows (dynamic library) and Linux (static library), however on macOS (static library) I get the following errors during linking:

Undefined symbols for architecture x86_64:
  "_AudioObjectAddPropertyListener", referenced from:
      _COREAUDIO_Init in libSDL2.a(SDL_coreaudio.m.o)
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioObjectGetPropertyData", referenced from:
      _prepare_device in libSDL2.a(SDL_coreaudio.m.o)
      _assign_device_to_audioqueue in libSDL2.a(SDL_coreaudio.m.o)
      _device_unplugged in libSDL2.a(SDL_coreaudio.m.o)
      _build_device_list in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioObjectGetPropertyDataSize", referenced from:
      _build_device_list in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioObjectRemovePropertyListener", referenced from:
      _COREAUDIO_CloseDevice in libSDL2.a(SDL_coreaudio.m.o)
      _COREAUDIO_Deinitialize in libSDL2.a(SDL_coreaudio.m.o)
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueAllocateBuffer", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueDispose", referenced from:
      _COREAUDIO_CloseDevice in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueEnqueueBuffer", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
      _inputCallback in libSDL2.a(SDL_coreaudio.m.o)
      _outputCallback in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueNewInput", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueNewOutput", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueSetProperty", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
      _assign_device_to_audioqueue in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueStart", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_AudioQueueStop", referenced from:
      _audioqueue_thread in libSDL2.a(SDL_coreaudio.m.o)
  "_CHHapticDynamicParameterIDHapticIntensityControl", referenced from:
      -[SDL_RumbleMotor setIntensity:] in libSDL2.a(SDL_mfijoystick.m.o)
  "_CHHapticEventParameterIDHapticIntensity", referenced from:
      -[SDL_RumbleMotor setIntensity:] in libSDL2.a(SDL_mfijoystick.m.o)
  "_CHHapticEventTypeHapticContinuous", referenced from:
      -[SDL_RumbleMotor setIntensity:] in libSDL2.a(SDL_mfijoystick.m.o)
  "_CVDisplayLinkCreateWithCGDisplay", referenced from:
      _Cocoa_InitModes in libSDL2.a(SDL_cocoamodes.m.o)
      _Cocoa_GetDisplayModes in libSDL2.a(SDL_cocoamodes.m.o)
  "_CVDisplayLinkGetNominalOutputVideoRefreshPeriod", referenced from:
      _GetDisplayMode in libSDL2.a(SDL_cocoamodes.m.o)
  "_CVDisplayLinkRelease", referenced from:
      _Cocoa_InitModes in libSDL2.a(SDL_cocoamodes.m.o)
      _Cocoa_GetDisplayModes in libSDL2.a(SDL_cocoamodes.m.o)
  "_FFCreateDevice", referenced from:
      _DARWIN_JoystickRumble in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticOpenFromService in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceCreateEffect", referenced from:
      _DARWIN_JoystickRumble in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticNewEffect in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceGetForceFeedbackCapabilities", referenced from:
      _SDL_SYS_HapticOpenFromService in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceGetForceFeedbackProperty", referenced from:
      _SDL_SYS_HapticOpenFromService in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceReleaseEffect", referenced from:
      _JoystickDeviceWasRemovedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticDestroyEffect in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceSendForceFeedbackCommand", referenced from:
      _DARWIN_JoystickRumble in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticOpenFromService in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticPause in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticUnpause in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticStopAll in libSDL2.a(SDL_syshaptic.c.o)
  "_FFDeviceSetForceFeedbackProperty", referenced from:
      _SDL_SYS_HapticSetGain in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticSetAutocenter in libSDL2.a(SDL_syshaptic.c.o)
  "_FFEffectGetEffectStatus", referenced from:
      _SDL_SYS_HapticGetEffectStatus in libSDL2.a(SDL_syshaptic.c.o)
  "_FFEffectSetParameters", referenced from:
      _DARWIN_JoystickRumble in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticUpdateEffect in libSDL2.a(SDL_syshaptic.c.o)
  "_FFEffectStart", referenced from:
      _DARWIN_JoystickRumble in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticRunEffect in libSDL2.a(SDL_syshaptic.c.o)
  "_FFEffectStop", referenced from:
      _SDL_SYS_HapticStopEffect in libSDL2.a(SDL_syshaptic.c.o)
  "_FFIsForceFeedback", referenced from:
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
  "_FFReleaseDevice", referenced from:
      _JoystickDeviceWasRemovedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
      _SDL_SYS_HapticOpenFromService in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticClose in libSDL2.a(SDL_syshaptic.c.o)
  "_GCControllerDidConnectNotification", referenced from:
      _IOS_JoystickInit in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_JoystickQuit in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCControllerDidDisconnectNotification", referenced from:
      _IOS_JoystickInit in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_JoystickQuit in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticDurationInfinite", referenced from:
      -[SDL_RumbleMotor setIntensity:] in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityHandles", referenced from:
      _IOS_JoystickGetCapabilities in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityLeftHandle", referenced from:
      _IOS_JoystickInitRumble in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityLeftTrigger", referenced from:
      _IOS_JoystickInitRumble in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityRightHandle", referenced from:
      _IOS_JoystickInitRumble in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityRightTrigger", referenced from:
      _IOS_JoystickInitRumble in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCHapticsLocalityTriggers", referenced from:
      _IOS_JoystickGetCapabilities in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonA", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonB", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonHome", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonMenu", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonOptions", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonX", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputButtonY", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputDualShockTouchpadButton", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_AddJoystickDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputDualShockTouchpadOne", referenced from:
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputDualShockTouchpadTwo", referenced from:
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputLeftShoulder", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputLeftThumbstick", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForAxis in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputLeftThumbstickButton", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputLeftTrigger", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForAxis in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputRightShoulder", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputRightThumbstick", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForAxis in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputRightThumbstickButton", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputRightTrigger", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForAxis in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputXboxPaddleFour", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_AddJoystickDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputXboxPaddleOne", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_AddJoystickDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputXboxPaddleThree", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_AddJoystickDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_GCInputXboxPaddleTwo", referenced from:
      _IOS_GameControllerGetAppleSFSymbolsNameForButton in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_AddJoystickDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _IOS_MFIJoystickUpdate in libSDL2.a(SDL_mfijoystick.m.o)
  "_IODispatchCalloutFromMessage", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
  "_IODisplayCreateInfoDictionary", referenced from:
      _Cocoa_InitModes in libSDL2.a(SDL_cocoamodes.m.o)
  "_IOHIDDeviceClose", referenced from:
      _PLATFORM_hid_close in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDDeviceCopyMatchingElements", referenced from:
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceGetProperty", referenced from:
      _PLATFORM_hid_enumerate in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_make_path in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_hid_open_path in libSDL2.a(SDL_hidapi.c.o)
      _get_string_property in libSDL2.a(SDL_hidapi.c.o)
      _IOS_SupportedHIDDevice in libSDL2.a(SDL_mfijoystick.m.o)
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceGetReport", referenced from:
      _PLATFORM_hid_get_feature_report in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDDeviceGetService", referenced from:
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceGetValue", referenced from:
      _DARWIN_JoystickUpdate in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceOpen", referenced from:
      _PLATFORM_hid_open_path in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDDeviceRegisterInputReportCallback", referenced from:
      _PLATFORM_hid_open_path in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_hid_close in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDDeviceRegisterRemovalCallback", referenced from:
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceScheduleWithRunLoop", referenced from:
      _PLATFORM_read_thread in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_hid_close in libSDL2.a(SDL_hidapi.c.o)
      _JoystickDeviceWasAddedCallback in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDDeviceSetReport", referenced from:
      _PLATFORM_hid_write in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_hid_send_feature_report in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDDeviceUnscheduleFromRunLoop", referenced from:
      _PLATFORM_hid_close in libSDL2.a(SDL_hidapi.c.o)
      _FreeDevice in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetChildren", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetCookie", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetLogicalMax", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetLogicalMin", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetType", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetTypeID", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetUsage", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDElementGetUsagePage", referenced from:
      _AddHIDElement in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerClose", referenced from:
      _PLATFORM_hid_exit in libSDL2.a(SDL_hidapi.c.o)
      _SDL_hid_exit_REAL in libSDL2.a(SDL_hidapi.c.o)
      _DARWIN_JoystickQuit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerCopyDevices", referenced from:
      _PLATFORM_hid_enumerate in libSDL2.a(SDL_hidapi.c.o)
      _PLATFORM_hid_open_path in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDManagerCreate", referenced from:
      _PLATFORM_hid_init in libSDL2.a(SDL_hidapi.c.o)
      _DARWIN_JoystickInit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerOpen", referenced from:
      _DARWIN_JoystickInit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerRegisterDeviceMatchingCallback", referenced from:
      _DARWIN_JoystickInit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerRegisterDeviceRemovalCallback", referenced from:
      _PLATFORM_hid_init in libSDL2.a(SDL_hidapi.c.o)
  "_IOHIDManagerScheduleWithRunLoop", referenced from:
      _PLATFORM_hid_init in libSDL2.a(SDL_hidapi.c.o)
      _DARWIN_JoystickInit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerSetDeviceMatchingMultiple", referenced from:
      _PLATFORM_hid_init in libSDL2.a(SDL_hidapi.c.o)
      _DARWIN_JoystickInit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDManagerUnscheduleFromRunLoop", referenced from:
      _DARWIN_JoystickQuit in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOHIDValueGetIntegerValue", referenced from:
      _DARWIN_JoystickUpdate in libSDL2.a(SDL_iokitjoystick.c.o)
  "_IOIteratorIsValid", referenced from:
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
  "_IOIteratorNext", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
      _CallbackIOServiceFunc in libSDL2.a(SDL_hidapi.c.o)
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
  "_IONotificationPortCreate", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
  "_IONotificationPortDestroy", referenced from:
      _SDL_hid_exit_REAL in libSDL2.a(SDL_hidapi.c.o)
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
  "_IONotificationPortGetMachPort", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
  "_IOObjectIsEqualTo", referenced from:
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
      _MacHaptic_MaybeRemoveDevice in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_JoystickSameHaptic in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticOpenFromJoystick in libSDL2.a(SDL_syshaptic.c.o)
  "_IOObjectRelease", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
      _CallbackIOServiceFunc in libSDL2.a(SDL_hidapi.c.o)
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
      _MacHaptic_MaybeRemoveDevice in libSDL2.a(SDL_syshaptic.c.o)
      _SDL_SYS_HapticQuit in libSDL2.a(SDL_syshaptic.c.o)
  "_IOObjectRetain", referenced from:
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
  "_IOPMAssertionCreateWithDescription", referenced from:
      _Cocoa_SuspendScreenSaver in libSDL2.a(SDL_cocoaevents.m.o)
  "_IOPMAssertionRelease", referenced from:
      _Cocoa_SuspendScreenSaver in libSDL2.a(SDL_cocoaevents.m.o)
  "_IOPSCopyPowerSourcesInfo", referenced from:
      _SDL_GetPowerInfo_MacOSX in libSDL2.a(SDL_syspower.c.o)
  "_IOPSCopyPowerSourcesList", referenced from:
      _SDL_GetPowerInfo_MacOSX in libSDL2.a(SDL_syspower.c.o)
  "_IOPSGetPowerSourceDescription", referenced from:
      _SDL_GetPowerInfo_MacOSX in libSDL2.a(SDL_syspower.c.o)
  "_IORegistryEntryCreateCFProperties", referenced from:
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
  "_IORegistryEntryGetParentEntry", referenced from:
      _MacHaptic_MaybeAddDevice in libSDL2.a(SDL_syshaptic.c.o)
  "_IOServiceAddMatchingNotification", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
  "_IOServiceGetMatchingServices", referenced from:
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
  "_IOServiceMatching", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
  "_KBGetLayoutType", referenced from:
      _Cocoa_HandleKeyEvent in libSDL2.a(SDL_cocoakeyboard.m.o)
  "_LMGetKbdType", referenced from:
      _UpdateKeymap in libSDL2.a(SDL_cocoakeyboard.m.o)
      _Cocoa_HandleKeyEvent in libSDL2.a(SDL_cocoakeyboard.m.o)
  "_MTLCreateSystemDefaultDevice", referenced from:
      _METAL_CreateRenderer in libSDL2.a(SDL_render_metal.m.o)
  "_OBJC_CLASS_$_CHHapticDynamicParameter", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_CHHapticEvent", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_CHHapticEventParameter", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_CHHapticPattern", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_GCColor", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_GCController", referenced from:
      objc-class-ref in libSDL2.a(SDL_mfijoystick.m.o)
  "_OBJC_CLASS_$_MTLRenderPassDescriptor", referenced from:
      objc-class-ref in libSDL2.a(SDL_render_metal.m.o)
  "_OBJC_CLASS_$_MTLRenderPipelineDescriptor", referenced from:
      objc-class-ref in libSDL2.a(SDL_render_metal.m.o)
  "_OBJC_CLASS_$_MTLSamplerDescriptor", referenced from:
      objc-class-ref in libSDL2.a(SDL_render_metal.m.o)
  "_OBJC_CLASS_$_MTLTextureDescriptor", referenced from:
      objc-class-ref in libSDL2.a(SDL_render_metal.m.o)
  "_OBJC_CLASS_$_MTLVertexDescriptor", referenced from:
      objc-class-ref in libSDL2.a(SDL_render_metal.m.o)
  "_TISCopyCurrentKeyboardLayoutInputSource", referenced from:
      _UpdateKeymap in libSDL2.a(SDL_cocoakeyboard.m.o)
  "_TISGetInputSourceProperty", referenced from:
      _UpdateKeymap in libSDL2.a(SDL_cocoakeyboard.m.o)
  "_iconv", referenced from:
      _SDL_iconv_REAL in libSDL2.a(SDL_iconv.c.o)
      _SDL_iconv_string_REAL in libSDL2.a(SDL_iconv.c.o)
     (maybe you meant: _SDL_iconv_string, _SDL_iconv_open_REAL , _SDL_iconv_close_REAL , _SDL_iconv_REAL , _SDL_iconv_string_REAL , _SDL_iconv_close , _SDL_iconv_open , _SDL_iconv )
  "_iconv_close", referenced from:
      _SDL_iconv_close_REAL in libSDL2.a(SDL_iconv.c.o)
      _SDL_iconv_string_REAL in libSDL2.a(SDL_iconv.c.o)
     (maybe you meant: _SDL_iconv_close_REAL, _SDL_iconv_close )
  "_iconv_open", referenced from:
      _SDL_iconv_open_REAL in libSDL2.a(SDL_iconv.c.o)
      _SDL_iconv_string_REAL in libSDL2.a(SDL_iconv.c.o)
     (maybe you meant: _SDL_iconv_open_REAL, _SDL_iconv_open )
  "_kIOMasterPortDefault", referenced from:
      _SDL_hid_device_change_count_REAL in libSDL2.a(SDL_hidapi.c.o)
      _SDL_SYS_HapticInit in libSDL2.a(SDL_syshaptic.c.o)
  "_kTISPropertyUnicodeKeyLayoutData", referenced from:
      _UpdateKeymap in libSDL2.a(SDL_cocoakeyboard.m.o)

I use the precompiled SDL2 Framework for MacOS without any problems. Is there a specific reason you’re compiling it from source?

Looks like you need to link to CoreAudio.

Is there a specific reason you’re compiling it from source?

I prefer my apps to be self-contained and to not rely on system-wide installed libraries. And installing libraries globally often causes versioning issues if multiple projects rely on different versions of the same library.

Anyway I’ve tried your approach, but now I have compilation errors because ImGui includes SDL like <SDL.h> and not like <SDL2/SDL.h> which Apple frameworks mandate. And I’m using ImGui as a submodule, so modifying its sources is not something I’d really like to do, especially when it works on all other platforms.

Looking at the symbols I see that CoreAudio is definitely not the only library needed. In fact, it seems that all the platform dependent libraries which SDL needs on macOS are missing. But I don’t get how I would link them, because, for example, doing -lCoreAudio is not enough and only yields an error.

Anyway, to further test this I’ve temporarily modified all the inclusions of SDL in my project, and the framework approach does indeed work correctly. So it seems the issue might be in the way vcpkg compiles SDL on macOS. I’ve created an issue on their GitHub.

1 Like

Of course, but I simply embed the SDL (and SDL_ttf, SDL_net) frameworks in my app, it’s no less “self-contained” than had I built them from source.

I do have to use install_name_tool to change the path to the frameworks from the system-wide location to the local copy in the app:

install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 "@executable_path/../Frameworks/SDL2.framework/Versions/A/SDL2" BBCBasic.app/Contents/Resources/bbcsdl
install_name_tool -change @rpath/SDL2_ttf.framework/Versions/A/SDL2_ttf "@executable_path/../Frameworks/SDL2_ttf.framework/Versions/A/SDL2_ttf" BBCBasic.app/Contents/Resources/bbcsdl
install_name_tool -change @rpath/SDL2_net.framework/Versions/A/SDL2_net "@executable_path/../Frameworks/SDL2_net.framework/Versions/A/SDL2_net" BBCBasic.app/Contents/Resources/bbcsdl
1 Like