Sign in Join

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

Mailing lists / fpc-pascal / 2009-03

Mac OS X SDL without gcc or XCode

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

dmitry boyarintsev

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 easily.
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 '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.

uses
  ...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.

Thanks,
Dmitry

P.S.
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.

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote 5 lines
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

[snip]

sdl unit (at fpc-package) still links SDLmain and libSDL libraries, that should be removed (otherwise there might be linker errors).

There are two different versions of SDL for Mac OS X. On the one hand there is the framework version, which is discussed above (and the one you get if you download the binary version from libsdl.org). On the other hand, there is also a "classic unix" version (no framework, just a bunch of separate libraries) which you get by default if you compile SDL from sources (or if you install it using Fink, and possibly also if you install it using MacPorts).

In this case, libSDLmain.a is always available in pre-compiled form (it's automatically compiled along with the rest of the sources). That's also why the FPC SDL unit always links against against that library (so that it works without having to add anything extra in the main program.).

When FPC ships by default with Objective-C support, your unit can be included instead and this can be changed. Until then, I prefer to keep things the way they are now.

Jonas

dmitry boyarintsev
to Jonas Maebe
In this case, libSDLmain.a is always available in pre-compiled form (it's automatically compiled along with the rest of the sources). That's also why the FPC SDL unit always links against against that library (so that it works without having to add anything extra in the main program.).

Thanks for the info. Never tried to compile SDL sources or get it via Fink or MacPort.
the only purpose, that passdlmain can be usefull, is extending (customizing) application menu, using pascal, rather than obj-c.

Also, speaking about sdl header. Correct if i'm wrong, but SDL tries to link XLib and/or X11 library under Darwin, even if these libs are not to be used?

Thanks,
Dmitry

P.S. I'm going to copy-paste your email to the wiki (about details on how-to get SDL lib, instead of framework), if you don't mind.

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote 12 lines
> In this case, libSDLmain.a is always available in pre-compiled form > (it's > automatically compiled along with the rest of the sources). That's > also why > the FPC SDL unit always links against against that library (so that > it works > without having to add anything extra in the main program.). Thanks for the info. Never tried to compile SDL sources or get it via Fink or MacPort. the only purpose, that passdlmain can be usefull, is extending (customizing) application menu, using pascal, rather than obj-c.

I think it would also be useful to make the default FPC SDL unit work with both the framework and unix library version: if your unit is be added to the uses clause of the sdl unit and the {$linklib SDLmain} is removed, then the unit should always work (since, as far as I know, the SDLmain.m file in the framework is simply the source file of libSDLmain.a).

Also, speaking about sdl header. Correct if i'm wrong, but SDL tries to link XLib and/or X11 library under Darwin, even if these libs are not to be used?

Yes, that can still be removed.

P.S. I'm going to copy-paste your email to the wiki (about details on how-to get SDL lib, instead of framework), if you don't mind.

No problem.

Jonas

dmitry boyarintsev
to Jonas Maebe
Yes, that can still be removed.

Removed...yes, but shall it be removed in fpc headers? Or should it be removed in jedi-sdl headers first, and only after that fpc sdl headers will be updated?
I could make a patch, removing x11 dependancy for darwin, but something tells me, that it would not be accepted that easy :)

No problem.

done. http://wiki.freepascal.org/FPC_and_SDL#Mac_OS_X_specific_issues I hope it helps any fpc-osx-sdl-newcomers to understand that they need library rather than framework :)

Thanks,
Dmitry

Joseph Montanez
to dmitry boyarintsev

I am also using sdl via macports but when I run an sdl demo, i get:

"2009-03-21 16:25:08.178 test[694:10b] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz."

Am i doing something wrong?

fpc -Fu/usr/local/lib/fpc/2.2.2/units/i386-darwin/sdl -Fl/opt/local/lib test.pas

and from the wili using:
{$linklib gcc}
{$linklib SDLmain}
dmitry boyarintsev wrote 18 lines
> Yes, that can still be removed. Removed...yes, but shall it be removed in fpc headers?  Or should it be removed in jedi-sdl headers first, and only after that fpc sdl headers will be updated? I could make a patch, removing x11 dependancy for darwin, but something tells me, that it would not be accepted that easy :) > No problem. done. http://wiki.freepascal.org/FPC_and_SDL#Mac_OS_X_specific_issues I hope it helps any fpc-osx-sdl-newcomers to understand that they need library rather than framework :) Thanks, Dmitry _______________________________________________ fpc-pascal maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-pascal
dmitry boyarintsev
to Joseph Montanez
Show quoted text 5 lines
"2009-03-21 16:25:08.178 test[694:10b] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz." Am i doing something wrong?

Nothing. i've got the same warning too.
I suspect this is SDL framework implementation, and there's nothing we (SDL-users) can do about it (except for updating SDL framework after the next version is released).

i've googled a bit :
http://www.omnigroup.com/mailman/archive/macosx-dev/2001-August/030624.html yes, this mailling list is pretty old, but still code hasn't changed ever since! googling also shows that NSQuickDrawView is used in 1.2.x SDL tags.

if you have the latest SDL trunk, could you check if NSQuickDrawView usage has been removed? (they really should remove it!)

Thanks,
Dmitry