On 03/01/2020 18:33, Ryan Joseph via fpc-pascal wrote: >> On Jan 2, 2020, at 2:57 PM, Ryan Joseph <generic...@gmail.com> wrote: >> >> extern C_LINKAGE int SDL_main(int argc, char *argv[]); >> >> which they call from within the iOS event loop and that calls the programs >> main functions which was defined using -XMSDL_main > I still can't figure out how -XM works. Can anyone provide an example? When > ever I try to use it I get linker errors. > > I've basically just started with a trimmed down program that does nothing but > define an external new main function (like SDL does). From the SDL sources I > thought that it would now point to the main program body but I can't get past > linker errors. > > fpc main.pas -XMuser_main > > > > Undefined symbols for architecture x86_64: > "_P$TEST_$$_USER_MAIN$LONGINT$PCHAR$$LONGINT", referenced from: > _PASCALMAIN in main.o > "_main", referenced from: > start in crt1.10.5.o > (maybe you meant: _user_main) > > > program test; > uses > ctypes; > > function user_main(argc: cint; argv: pchar): cint; external;
You're missing a "cdecl;" here. > begin > user_main(0,''); > end. Additionally, you will also have to link in an object/library that does define a regular "main" function. And note that this will only work on libc-based targets (afaik only Darwin, Solaris, and AIX at this point). Jonas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal