Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-01

$PASCALMAINNAME error with SDL/IPhone

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ryan Joseph

I thought I had this working some years ago but I'm confused again. :)

When trying to use SDL on iPhone I include:

 {$PASCALMAINNAME SDL_main}

But when I compile I get a linker error:

Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)

Why is this?

Regards,
Ryan Joseph

Reply by email

Jonas Maebe
to Ryan Joseph
Ryan Joseph wrote 14 lines
I thought I had this working some years ago but I'm confused again. :) When trying to use SDL on iPhone I include:  {$PASCALMAINNAME SDL_main} But when I compile I get a linker error: Undefined symbols for architecture x86_64:   "_main", referenced from:      implicit entry/start for main executable      (maybe you meant: _SDL_main) Why is this?

It only works in your main program, not in a unit or so. Maybe that's the reason?

Jonas

Reply by email

Ryan Joseph
to Jonas Maebe
On Feb 1, 2022, at 3:15 AM, Jonas Maebe via fpc-pascal wrote: It only works in your main program, not in a unit or so. Maybe that's the reason?

The linker wants me to redefine "main" to clear the error but this doesn't make sense and the app crashes when launched. I.e.:

function main(argc: integer; argv: pchar): integer; cdecl; public;

https://stackoverflow.com/questions/11976084/why-sdl-defines-main-macro

states that SDL wants to rename your main function to SDL_main so that it can use its own main function (main I assume) which then calls out to your main function. I had old code from 2016 which appears to do this but for some reason now I'm getting this linker error.

My only guess is that the linker can't find the SDL main function in the framework, even though everything else links properly.

Regards,
Ryan Joseph

Reply by email

Ryan Joseph
to Ryan Joseph
On Feb 1, 2022, at 9:34 AM, Ryan Joseph wrote: My only guess is that the linker can't find the SDL main function in the framework, even though everything else links properly.

If anyone understands SDL I figured out how to get around this missing main linker error and program runs but then crashes. I've reported to SDL at https://discourse.libsdl.org/t/crash-in-uitextfield/34711 (along with my program if you're interested) but I don't have much hope because this could be Pascal related and they won't know anything about this.

Regards,
Ryan Joseph

Reply by email

Ryan Joseph
to Ryan Joseph
On Feb 1, 2022, at 9:22 PM, Ryan Joseph wrote: If anyone understands SDL I figured out how to get around this missing main linker error and program runs but then crashes. I've reported to SDL at https://discourse.libsdl.org/t/crash-in-uitextfield/34711 (along with my program if you're interested) but I don't have much hope because this could be Pascal related and they won't know anything about this.

Btw, here is the stack trace of my crash. Why is PASCALMAIN still there if I renamed it to SDL_main? Shouldn't that have changed?

Thread 1 Queue : com.apple.main-thread
(serial)

#0 0x00007fff2554864d in -[UIScrollView _adjustedContentOffsetForContentOffset:skipsAdjustmentIfScrolling:] ()

#1 0x00007fff25548f5d in -[UIScrollView _adjustContentOffsetIfNecessary] ()

#2 0x00007fff2551f4d7 in -[UIScrollView setFrame:] ()

#3 0x00007fff25588cb3 in UIViewCommonInitWithFrame ()

#4 0x00007fff25588672 in -[UIView initWithFrame:]
()

#5 0x00007fff2551b093 in -[UIScrollView initWithFrame:] ()

#6 0x00007fff25373471 in -[UIFieldEditor initWithTextField:] ()

#7 0x00007fff25392007 in -[UITextField _fieldEditor] ()

#8 0x00007fff25393d14 in -[UITextField _inputController] ()

#9 0x00007fff2538b5bc in -[UITextField setTextAlignment:] ()

#10 0x00007fff2538b742 in -[UITextField setDefaultTextAttributes:] ()

#11 0x00007fff2537d554 in __55-[UITextField _initWithFrame:textLayoutManagerEnabled:]_block_invoke ()

#12 0x00007fff25587486 in +[UIView _performSystemAppearanceModifications:] ()

#13 0x00007fff2537d3da in -[UITextField _initWithFrame:textLayoutManagerEnabled:] ()

#14 0x00000001094b87f9 in -[SDL_uikitviewcontroller initKeyboard] at /Users/ryanjoseph/Developer/SDL2-2.0.20/src/video/uikit/SDL_uikitviewcontroller.m:272 #15 0x00000001094b7f01 in -[SDL_uikitviewcontroller initWithSDLWindow:] at /Users/ryanjoseph/Developer/SDL2-2.0.20/src/video/uikit/SDL_uikitviewcontroller.m:95 #16 0x00000001094c7541 in SetupWindowData at /Users/ryanjoseph/Developer/SDL2-2.0.20/src/video/uikit/SDL_uikitwindow.m:145 #17 0x00000001094c7152 in UIKit_CreateWindow at /Users/ryanjoseph/Developer/SDL2-2.0.20/src/video/uikit/SDL_uikitwindow.m:221 #18 0x000000010952fff0 in SDL_CreateWindow at /Users/ryanjoseph/Developer/SDL2-2.0.20/src/video/SDL_video.c:1718 #19 0x0000000108c1ee6d in PASCALMAIN
()

#20 0x0000000108c4194c in FPC_SysEntry
()

#21 0x0000000108c1ed92 in FPC_SYSTEMMAIN ()

Regards,
Ryan Joseph

Reply by email