[fpc-pascal] Mac OS X SDL without gcc or XCode

dmitry boyarintsev skalogryz.lists at gmail.com
Tue Mar 17 14:52:39 CET 2009

Hello Pascal Developers

i've been wondering about SDL usage for Mac OS X.

OS X sdl, uses Cocoa, that means, application must be created and
started using obj-c. For the people, who don't know ObjC, there're a
some template projects that can be used together with C/C++ code
There're some fpc-sdl templates for XCode (at jedi-sdl). I'm using
Lazarus IDE (codetools mostly wanted feature) for development, and
using XCode is pain for me.
It's also possible to use precompiled library, as desctibed at this
forum thread: http://forum.lazarus.freepascal.org/index.php/topic,6192.15.html

But it's nicer, if even this gcc usagel can be avoided.

With recent advance in objective-c runtime usage, there's an option
not to use ObjC sources at all.
I've converted SDLmain.m (objective-c) to the passdlmain.pas pascal
unit (attached to this email), using objcrtl (see PasCocoa bindings)

now, using sdl with OSX becomes easier.
The only thing to do, is add the passdlmain unit to uses section.

  ...sdl, passdlmain..;

That's it. Objective-C application is created on start-up, and passed
to the pascal program then ready.

sdl unit (at fpc-package) still links SDLmain and libSDL libraries,
that should be removed (otherwise there might be linker errors).
passdlmain, links two required frameworks (SDL, Cocoa) and contains
compiler switch to rename main pascal function as required.

I hope you'll find this usefull.


objcrtl - is the wrapper lib around objective-c runtime (not
PasCocoa). It's designed, so objective-c runtime had the same
interface independant of objective-c version. Currently it works for
2.0 version (OSX Leopard) with a few wrappers complete, it can work
for 1.0 (Tiger and lower) too.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: passdlmain.pas.zip
Type: application/zip
Size: 3706 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20090317/80bd7f97/attachment.zip>

More information about the fpc-pascal mailing list