Howto: use command line with Frameworks

Well I have it 100% figured out now… [I need to write this down].

Thought I would share this with you all.

Here is the build rule for graywin.c test:

change:
#include "SDL.h"
to
#include <SDL/SDL.h>

then compile with the following:

cc -ISDL.framework/Headers -F$HOME/Library/Frameworks -framework SDL
-lobjc -framework AppKit -framework Foundation graywin.c SDLMain.m -o
graywin

The SDLMain.m was needed or I got all kinds of unused objective-c errors
which means you also need SDLMain.h as well.

AppKit and Foundation were mandatory.

Thanks for all the help and responses over the last few days!

I can more easily continue my porting work for Kyra now :slight_smile:

Dave

What you have done works, but the preferred method (for portability
purposes) is to always use #include “SDL.h”. This allows more
flexibility as to the location of the SDL headers on various different
build systems that might arise. The -I option passed to CC can add the
path the to headers (which you have done below). IMHO, it seems better
to correct somewhat trivial header problems like this with a compiler
flags rather than changing the code.

-DOn Wednesday, February 27, 2002, at 11:47 PM, David Leimbach wrote:

Well I have it 100% figured out now… [I need to write this down].

Thought I would share this with you all.

Here is the build rule for graywin.c test:

change:
#include "SDL.h"
to
#include <SDL/SDL.h>

then compile with the following:

cc -ISDL.framework/Headers -F$HOME/Library/Frameworks -framework SDL
-lobjc -framework AppKit -framework Foundation graywin.c SDLMain.m -o
graywin

The SDLMain.m was needed or I got all kinds of unused objective-c
errors which means you also need SDLMain.h as well.

AppKit and Foundation were mandatory.

Thanks for all the help and responses over the last few days!

I can more easily continue my porting work for Kyra now :slight_smile:

Dave


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

I agree
For a project I am working on I am making “dummy headers”. I don’t want
to have to know in advance that the headers are in
…/Frameworks/SDL.framework/Headers.

It could be installed in many places.

My dummy header idea works like this

make a directory called “dummy_headers” or whatever.

Each dummy header works like this:

SDL.h:
#include <SDL/SDL.h>

Then you use -Idummy_headers and voila. The code can stay as "SDL.h"
which will be the dummy header that correctly “chain-includes” the
Framework style SDL.h.

Good? Bad? It doesn’t rely on previous knowledge of where the framework
was installed on an OS X box…

I like it so far.

DaveOn Wednesday, February 27, 2002, at 11:12 PM, Darrell Walisser wrote:

What you have done works, but the preferred method (for
portability purposes) is to always use #include “SDL.h”. This allows
more flexibility as to the location of the SDL headers on various
different build systems that might arise. The -I option passed to CC
can add the path the to headers (which you have done below). IMHO, it
seems better to correct somewhat trivial header problems like this with
a compiler flags rather than changing the code.

-D

On Wednesday, February 27, 2002, at 11:47 PM, David Leimbach wrote:

Well I have it 100% figured out now… [I need to write this down].

Thought I would share this with you all.

Here is the build rule for graywin.c test:

change:
#include "SDL.h"
to
#include <SDL/SDL.h>

then compile with the following:

cc -ISDL.framework/Headers -F$HOME/Library/Frameworks -framework SDL
-lobjc -framework AppKit -framework Foundation graywin.c SDLMain.m -o
graywin

The SDLMain.m was needed or I got all kinds of unused objective-c
errors which means you also need SDLMain.h as well.

AppKit and Foundation were mandatory.

Thanks for all the help and responses over the last few days!

I can more easily continue my porting work for Kyra now :slight_smile:

Dave


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


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

For a project I am working on I am making “dummy headers”. I don’t
want to have to know in advance that the headers are in
…/Frameworks/SDL.framework/Headers.

My dummy header idea works like this

make a directory called “dummy_headers” or whatever.

Each dummy header works like this:

SDL.h:
#include <SDL/SDL.h>

Then you use -Idummy_headers and voila. The code can stay as "SDL.h"
which will be the dummy header that correctly “chain-includes” the
Framework style SDL.h.

Good? Bad? It doesn’t rely on previous knowledge of where the
framework was installed on an OS X box…

I agree this is a good idea. I’ve done similar things, for example with
OpenGL to locate GL/gl.h et al. One caveat is that it may be possible in
some situations to get a recursive #include chain that loops back on
itself. I’ve never seen this on GCC (as it may be smart enough to avoid
such things - I’m not sure), but CodeWarrior tends to do this without
some tweaking (CodeWarrior has the notion of recursive and non-recursive
search paths, the default is recursive).

-D

I agree this is a good idea. I’ve done similar things, for example with
OpenGL to locate GL/gl.h et al. One caveat is that it may be possible
in some situations to get a recursive #include chain that loops back on
itself. I’ve never seen this on GCC (as it may be smart enough to avoid
such things - I’m not sure), but CodeWarrior tends to do this without
some tweaking (CodeWarrior has the notion of recursive and
non-recursive search paths, the default is recursive).

I will be sure to keep my eyes open for the CodeWarrior situation then.
I was initially worried about infinite recursion as well but I figured
that the framework/header.h rule in the special preprocessor would
handle that. Perhaps codewarrior can use the output of the Apple
modified frameworks compatible preprocessor [cpp-precomp]?> -D


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