[SDL] MacOS and static linking problem

Kevin Shanahan kmshanah at disenchant.net
Tue Mar 26 13:45:05 PDT 2013


On Tue, Mar 26, 2013 at 05:48:25PM +0100, Gabriele Greco wrote:
> >
> > cc -o Launcher foo.o bar.o ... -arch x86_64 -static `sdl2-config
> > --static-libs`
> >
> >
> You should remove for sure -static from your command line, otherwise GCC
> will try to find a static library for everything, also system frameworks,
> and,....

Ok, will do. I added that later when I realised that SDL was still
being linked dynamically.  That was the only option I could find. And
I thought it wasn't right when the the man page said 'Only used
building the kernel'. :)

> And `sdl2-config --static-libs` evalutes to:
> >
> > -L/usr/local/lib -lSDL2 -lm -liconv -Wl,-framework,OpenGL
> > -Wl,-framework,ForceFeedback -lobjc -Wl,-framework,Cocoa
> > -Wl,-framework,Carbon -Wl,-framework,IOKit -Wl,-framework,CoreAudio
> > -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit
> >
> 
>  ...as far as I can see from your --static-libs, except if you have build
> SDL as static only with --disable-shared, the output of sdl-config is
> wrong, it should contain something like:
> 
> [...]   -Wl,"-Bstatic"  -lSDL2 -Wl,"-Bdynamic" [...]

It seems -Bstatic is no longer a recognised linker option:

ld: unknown option: -Bstatic

> Anyway usually there is no need to compile statically on OSX, since you can
> distribute SDL as framework inside your application bundle.

Thanks, I will look into this option.

Cheers,
Kevin.



More information about the SDL mailing list