[SDL] tearring graphics

Chris Thielen chris at luethy.net
Tue Jan 28 20:56:00 PST 2003


allow: post

Am Donnerstag, 16.01.03 um 22:55 Uhr schrieb Aaron Sullivan:

> The whole statically linked licensing issue had me intrigued because I 
> don't know how to distribute a commercial release the correct way on 
> MacOS X.
>
> I have been unable to find a way to make a dynamically linked 
> executable with MacOS X.
> The setup for SDL was effortless. It even creates an SDL Application 
> option when starting a new Project with Project Builder, but there is 
> no .dll it links with or anything similar that I can see.
> Does anyone have experience creating a dynamically linked app for 
> MacOS X that can share the process with me?
>
> As close as I can tell I would have to have the user install the SDL 
> frameworks in their local library folder. (?)
>
> Aaron
>

Look at your Project Builder project: under Targets/Linker settings, 
you should find a "-framework SDL" in the box "other Mach-O Linker 
Flags". This links your executable against the SDL.framework. Note that 
you should _not_ have the SDL.framework installed in your user 
directory for this: it should be in /Library/Frameworks. Otherwise, the 
path will be hardcoded to your home dir in the executable, which is not 
what you want. (The SDL package installs the framework into the home 
dir by default; this should be changed, perhaps).

You can examine the dynamically linked libraries in Terminal by 
changing to build/AppName.app/Contents/MacOS and doing an otool -L 
AppName . This gives you an output like this:

$ otool -L chromium
chromium:
         /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL 
(compatibility version 1.0.0, current version 1.0.0)
         /Users/jobi/Library/Frameworks/SDL.framework/Versions/A/SDL 
(compatibility version 1.0.0, current version 1.0.0)
         /usr/lib/libz.1.1.3.dylib (compatibility version 1.0.0, current 
version 1.1.3)
         
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 
(compatibility version 300.0.0, current version 425.0.0)
         /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit 
(compatibility version 45.0.0, current version 620.0.0)
         /System/Library/Frameworks/AGL.framework/Versions/A/AGL 
(compatibility version 1.0.0, current version 1.0.0)
         /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon 
(compatibility version 2.0.0, current version 122.0.0)

Note that I linked this app with SDL in my home dir. With SDL in 
/Library/Frameworks, this would look like

$ otool -L enigma
enigma:
         @executable_path/../Frameworks/SDL.framework/Versions/A/SDL 
(compatibility version 1.0.0, current version 1.0.0)
         /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa 
(compatibility version 1.0.0, current version 8.0.0)
         
@executable_path/../Frameworks/SDL_image.framework/Versions/A/SDL_image 
(compatibility version 1.0.0, current version 1.0.0)
         
@executable_path/../Frameworks/SDL_mixer.framework/Versions/A/SDL_mixer 
(compatibility version 1.0.0, current version 1.0.0)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, 
current version 63.0.0)

(here I linked with SDL_image and SDL_mixer additionally). You see that 
the hard coded path for SDL.framework refers to ../Frameworks: this 
means that you can put SDL.framework into you .app bundle in 
AppName.app/Contents/Frameworks, and have it both "statically linked" 
(i.e. always distributed with the .app) and exchangeable. The system 
will, according to documentation, always use the framework bundle with 
the highest version. You want to read 
/Developer/Documentation/Essentials/SystemOverview/index.html . (Come 
on. You know you do :-) )

When porting your app, don't forget that Mac users expect your 
application to be a single bundle. The standard SDLMain.m that comes 
with SDL sadly does the following:
     if (shouldChdir)
     {
       assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's 
parent */
       assert ( chdir ("../../../") == 0 ); /* chdir to the .app's 
parent */
     }
which motivates to store the data in the .app's parent directory. I 
always change this to
     if (shouldChdir)
     {
       assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's 
parent */
       assert ( chdir ("../Resources/") == 0 ); /* chdir to the 
Resources folder in the .app bundle */
     }
and put my stuff into AppName.app/Contents/Resources.

HTH,

Johannes Fortmann
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 4965 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030118/8d3c60cc/attachment-0008.bin>


More information about the SDL mailing list