MacOSX app bundle

Maybe it’s a faq, but I’m not able to google the net for an exhaustive
source…

How can I build an OSX app bundle (using SDL) without Project Builder or
CodeWarrior but with a plain makefile?

I’m able to build and run my project with a makefile largely similar to
the unix one, I’ve added a few directives to build the XXX.app directory
and place the executable there but the problem I have is with libraries,
the executable always search for the dylib with an ABSOLUTE path (eg
/usr/local/lib/libSDL.dylib), how can I tell linker to search for
libraries installed in a directory inside the app bundle?

I’ve seen a post about the use of frameworks instead of the dylib, but
in that way I’m not able to link at all!

I’m actually linking in a very simple way:

etw:
gcc -o $@ $(OBJECTS) sdl-config --libs

(OBJECTS include SDLMain.m)

The SDL release is the 1.2.6 one installed from sources.

Bye,
Gabry

I’m able to build and run my project with a makefile largely similar to
the unix one, I’ve added a few directives to build the XXX.app directory
and place the executable there but the problem I have is with libraries,
the executable always search for the dylib with an ABSOLUTE path (eg
/usr/local/lib/libSDL.dylib), how can I tell linker to search for
libraries installed in a directory inside the app bundle?

My favorite hack is to build SDL from source, but manually link it.
Add/replace the -install_name linker command with:

-install_name @executable_path/libSDL-1.2.0.dylib

Link your program against that library. It will look for it in the same
directory as the binary at runtime (so copy it into
XXX.app/Contents/MacOS with your binary).

This isn’t really “the Mac way”, but it’s much more comfortable and
obvious to my Linux background.

–ryan.

Or try using -framework SDL instead of -lSDL
Using -framework requires users to have the offical SDL package via libsdl.org
installed though…
Which is better/recommended? I have been use the -framework command for my
binaries.
Please forgive me if i dont have the exact linking syntax corrent :slight_smile:

Too bad sdl-config for macos x wasnt configurable to return -framework vs.
-lSDL. (or is it? :slight_smile: )
-Jeremy

— “Ryan C. Gordon” wrote:>

I’m able to build and run my project with a makefile largely similar to
the unix one, I’ve added a few directives to build the XXX.app directory
and place the executable there but the problem I have is with libraries,
the executable always search for the dylib with an ABSOLUTE path (eg
/usr/local/lib/libSDL.dylib), how can I tell linker to search for
libraries installed in a directory inside the app bundle?

My favorite hack is to build SDL from source, but manually link it.
Add/replace the -install_name linker command with:

-install_name @executable_path/libSDL-1.2.0.dylib

Link your program against that library. It will look for it in the same
directory as the binary at runtime (so copy it into
XXX.app/Contents/MacOS with your binary).

This isn’t really “the Mac way”, but it’s much more comfortable and
obvious to my Linux background.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

=====
http://jeremy.doverstreet.dhs.org

Ryan C. Gordon wrote:

My favorite hack is to build SDL from source, but manually link it.
Add/replace the -install_name linker command with:

-install_name @executable_path/libSDL-1.2.0.dylib

I’ve tried this way and it works but I need to remember to manually
change SDL makefile every time a compile it… :slight_smile:

Digging in the ML archives I’ve found another way, cleaner IMHO, but it
seems not to work, this approach relies on the -dylib_file linker
command, I really don’t know why it doesn’t work as it should, here is
the linker command line:

gcc -o etw SDLMain.o highdirent.o cpu.o human.o myiff.o specials.o
anim.o crowd.o intro.o os_control.o squadre.o arbitro.o data.o league.o
os_init.o tables.o arcade.o dati_vel.o lists.o os_video.o tactics.o
chunkyblitting.o display.o loops.o palla.o teams.o commento.o etw.o
main.o portiere.o freq.o computer.o etw_locale.o menu.o radar.o
utility.o config.o font.o menu_config.o replay.o velocita_g.o
connection.o generic_video.o menu_data.o sound.o wc.o control.o gfx.o
menu_font.o special.o network.o highsocket.o -dylib_file
/usr/local/lib/libSDL-1.2.0.dylib:@executable_path/libSDL-1.2.0.dylib
-lSDL -framework Cocoa -framework OpenGL

[:~/ETW/src/etw] gabry% otool -L etw
etw:
/usr/local/lib/libSDL-1.2.0.dylib (compatibility version 1.0.0,
current version 1.5.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
(compatibility version 1.0.0, current version 8.0.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
(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)

Bye,
Gabry