SDL3.4 and Intel-Mac (import xcframework)

Mac OSX specific forum
GPI
PureBasic Expert
PureBasic Expert
Posts: 1400
Joined: Fri Apr 25, 2003 6:41 pm

SDL3.4 and Intel-Mac (import xcframework)

Post by GPI »

I have installed the SDL3-Framework from the original-git-hub:
https://github.com/libsdl-org/SDL/relea ... ease-3.4.2

and with Windows/Linux everything works, but on a Intel it will crash (unexpected debugger termination).

Simple example-code

Code: Select all

importc "/Library/Frameworks/SDL3.xcframework/macos-arm64_x86_64/SDL3.framework/SDL3"
endimport
debug "test"
User avatar
kenmo
Addict
Addict
Posts: 2082
Joined: Tue Dec 23, 2003 3:54 am

Re: SDL3.4 and Intel-Mac (import xcframework)

Post by kenmo »

Looks like you're importing an Arm library on an Intel system... what do you expect should happen? (Serious question. Not sarcastic. I'm no expert on these libraries and also I use Mac less than Linux/Windows.)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1400
Joined: Fri Apr 25, 2003 6:41 pm

Re: SDL3.4 and Intel-Mac (import xcframework)

Post by GPI »

As far as I understand it is a combined lib for ARM64, X86 and X64. A "universal binary".
But I think that this could be the main problem, that Purebasic can't handle universal binary libs...
Fred
Administrator
Administrator
Posts: 18531
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SDL3.4 and Intel-Mac (import xcframework)

Post by Fred »

We use the standard linker, so it should handle it
User avatar
Piero
Addict
Addict
Posts: 1214
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: SDL3.4 and Intel-Mac (import xcframework)

Post by Piero »

GPI wrote: Tue Mar 03, 2026 7:38 pmimportc

Code: Select all

; SDL 3 Test

Procedure.s UpperDir(path$, level = 1, setcurrdir = #False) ; get enclosing folder (multilevel)
   Protected i, oldcurrdir$ = GetCurrentDirectory()
   path$ = GetPathPart(path$) ; in case of file
   For i = 1 To level : path$ + ".." + #PS$ : Next
   SetCurrentDirectory(path$)
   path$ = GetCurrentDirectory()
   If Not setcurrdir : SetCurrentDirectory(oldcurrdir$) : EndIf
   ProcedureReturn path$
EndProcedure

Macro dq : "
EndMacro

Macro Fun(f,i=0)
   Global f#._#f = GetFunction(i, dq#f#dq)
EndMacro

PrototypeC.i _SDL_Init(flags.l)
PrototypeC _SDL_Quit()
PrototypeC _SDL_PumpEvents()
PrototypeC.i _SDL_CreateWindowAndRenderer(*title, width.i, height.i, window_flags.l, *pWindow, *pRenderer)
PrototypeC _SDL_DestroyRenderer(*renderer)
PrototypeC _SDL_DestroyWindow(*window)
PrototypeC.i _SDL_SetRenderDrawColor(*renderer, r.a, g.a, b.a, a.a)
PrototypeC.i _SDL_RenderClear(*renderer)
PrototypeC _SDL_RenderPresent(*renderer)

; To make a standalone .app, copy SDL3.framework into your app.
; Put it into folder: your.app/Contents/Frameworks/ (needed only once!)
; Then you can use:
; If OpenLibrary(0, UpperDir(ProgramFilename())+"Frameworks/SDL3.framework/SDL3")

If OpenLibrary(0, "SDL3.framework/SDL3") ; Framework on source folder for debugging
   Fun(SDL_Init)
   Fun(SDL_Quit)
   Fun(SDL_PumpEvents)
   Fun(SDL_CreateWindowAndRenderer)
   Fun(SDL_DestroyRenderer)
   Fun(SDL_DestroyWindow)
   Fun(SDL_SetRenderDrawColor)
   Fun(SDL_RenderClear)
   Fun(SDL_RenderPresent)
   If (SDL_Init($20))
      If (SDL_CreateWindowAndRenderer(UTF8("SDL3 Test"), 640, 480, 0, @*win, @*ren))
         SDL_SetRenderDrawColor(*ren, 0, 255, 0, 255)
         SDL_RenderClear(*ren)
         SDL_RenderPresent(*ren)
         For i=0 to 99
            SDL_PumpEvents() ; fix for Mac
         Next
         Delay(2000)
         SDL_DestroyRenderer(*ren)
         SDL_DestroyWindow(*win)
      EndIf
      SDL_Quit()
   EndIf
EndIf
 
PS:
Image
Post Reply