OS X and sdl2-config --static-libs

Hi all,

I’m used to building some project snapshots with static libs and used to get those for SDL 1.2x via “sdl-config --static-libs”.

Now that one of them has been partially ported to SDL2 I found that “sdl2-config --static-libs” does NOT return the static libs of SDL2.

When I compared the two configs I found that

  • sdl-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

  echo -L${exec_prefix}/lib  ${libdir}/libSDL.a  -lm -liconv -Wl,manyframeworks
  • sdl2-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

  echo -L${exec_prefix}/lib  ${libdir}/libSDLmain.a ${libdir}/libSDL.a  -Wl,manyframeworks

Further digging led me to configure.in which is missing the special OS X case that SDL 1.2x had:

Code:
case “$ARCH” in
macosx)
if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
fi
if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
fi
# Evil hack to allow static linking on Mac OS X
SDL_STATIC_LIBS="${libdir}/libSDLmain.a ${libdir}/libSDL.a $EXTRA_LDFLAGS"
;;
*)
SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
;;
esac

Then traced it back to revison Revision: 6303 and bug https://bugzilla.libsdl.org/show_bug.cgi?id=1429
I would still like to build statically with this option. I mean, I can just manually edit sdl2-config but I want to understand why you removed it.
As per the bug report I don’t understand how --libs could be affected by this. But then I hardly understand everything around code :slight_smile:

And Cocoa only. No carbon anymore.

JosephOn Sat, Jan 10, 2015 at 11:44:03PM +0000, Dominus wrote:

Dominus wrote:

Hi all,

I’m used to building some project snapshots with static libs and used to get those for SDL 1.2x via “sdl-config --static-libs”.

Now that one of them has been partially ported to SDL2 I found that “sdl2-config --static-libs” does NOT return the static libs of SDL2.

When I compared the two configs I found that

  • sdl-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

  echo -L${exec_prefix}/lib  ${libdir}/libSDL.a  -lm -liconv -Wl,manyframeworks
  • sdl2-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

  echo -L${exec_prefix}/lib  ${libdir}/libSDLmain.a ${libdir}/libSDL.a  -Wl,manyframeworks

Further digging led me to configure.in which is missing the special OS X case that SDL 1.2x had:

Code:
case “$ARCH” in
macosx)
if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
fi
if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
fi
# Evil hack to allow static linking on Mac OS X
SDL_STATIC_LIBS="${libdir}/libSDLmain.a ${libdir}/libSDL.a $EXTRA_LDFLAGS"
;;
*)
SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
;;
esac

Then traced it back to revison Revision: 6303 and bug https://bugzilla.libsdl.org/show_bug.cgi?id=1429
I would still like to build statically with this option. I mean, I can just manually edit sdl2-config but I want to understand why you removed it.
As per the bug report I don’t understand how --libs could be affected by this. But then I hardly understand everything around code :slight_smile:

Also you might need to change docs/README-macosx.md accordingly.

Yes, that should work, but it’s not practical to not have the shared lib files :frowning:

John wrote:> It works if you built the static libs when you built SDL, and the shared libs

are not present in that dir. Roughly,

build SDL2 like this

$ ./configure --disable-shared --prefix=foo

link your app with this

$ foo/bin/sdl2-config --static-libs

On 01/12/2015 07:45 PM, Dominus wrote:

Joseph Carter wrote:

On Sat, Jan 10, 2015 at 11:44:03PM +0000, Dominus wrote:

Dominus wrote:

Hi all,

I’m used to building some project snapshots with static libs and used to get those for SDL 1.2x via “sdl-config --static-libs”.

Now that one of them has been partially ported to SDL2 I found that “sdl2-config --static-libs” does NOT return the static libs of SDL2.

When I compared the two configs I found that

  • sdl-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

echo -L${exec_prefix}/lib ${libdir}/libSDL.a -lm -liconv -Wl,manyframeworks

  • sdl2-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

echo -L${exec_prefix}/lib ${libdir}/libSDLmain.a ${libdir}/libSDL.a -Wl,manyframeworks

Further digging led me to configure.in which is missing the special OS X case that SDL 1.2x had:

Code:
case “$ARCH” in
macosx)
if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
fi
if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
fi

Evil hack to allow static linking on Mac OS X

SDL_STATIC_LIBS="${libdir}/libSDLmain.a ${libdir}/libSDL.a $EXTRA_LDFLAGS"
;;
*)
SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
;;
esac

Then traced it back to revison Revision: 6303 and bug https://bugzilla.libsdl.org/show_bug.cgi?id=1429
I would still like to build statically with this option. I mean, I can just manually edit sdl2-config but I want to understand why you removed it.
As per the bug report I don’t understand how --libs could be affected by this. But then I hardly understand everything around code :slight_smile:

Also you might need to change docs/README-macosx.md accordingly.

And Cocoa only. No carbon anymore.

Joseph

It’s set somewhere else in configure.in these days, as the carbon framework is still needed (SDL_cocoakeyboards.m and SDL_cocoamodes.m).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

A simple fix is to cut out the middlemen (sdl2-config and autoconf) from your
build, and just link directly to /prefix/lib/libSDL.a or libSDL.so as you like.

Anotehr simple fix is to post-process the output of sdl2-config to replace
-lSDL2 with /prefix/lib/SDL2.a as needed.On 01/14/2015 04:26 AM, Dominus wrote:

Yes, that should work, but it’s not practical to not have the shared lib files :frowning:

John wrote:

It works if you built the static libs when you built SDL, and the shared libs
are not present in that dir. Roughly,

build SDL2 like this

$ ./configure --disable-shared --prefix=foo

link your app with this

$ foo/bin/sdl2-config --static-libs

On 01/12/2015 07:45 PM, Dominus wrote:

Joseph Carter wrote:

On Sat, Jan 10, 2015 at 11:44:03PM +0000, Dominus wrote:

Dominus wrote:

Hi all,

I’m used to building some project snapshots with static libs and used to get those for SDL 1.2x via “sdl-config --static-libs”.

Now that one of them has been partially ported to SDL2 I found that “sdl2-config --static-libs” does NOT return the static libs of SDL2.

When I compared the two configs I found that

  • sdl-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

echo -L${exec_prefix}/lib ${libdir}/libSDL.a -lm -liconv -Wl,manyframeworks

  • sdl2-config --static-libs has the lines

Code:
–static-libs)

–libs|–static-libs)

echo -L${exec_prefix}/lib ${libdir}/libSDLmain.a ${libdir}/libSDL.a -Wl,manyframeworks

Further digging led me to configure.in which is missing the special OS X case that SDL 1.2x had:

Code:
case “$ARCH” in
macosx)
if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Cocoa"
fi
if test x$enable_video = xyes -a x$enable_video_carbon = xyes; then
SDL_LIBS="$SDL_LIBS -Wl,-framework,Carbon"
fi

Evil hack to allow static linking on Mac OS X

SDL_STATIC_LIBS="${libdir}/libSDLmain.a ${libdir}/libSDL.a $EXTRA_LDFLAGS"
;;
*)
SDL_STATIC_LIBS="$SDL_LIBS $EXTRA_LDFLAGS"
;;
esac

Then traced it back to revison Revision: 6303 and bug https://bugzilla.libsdl.org/show_bug.cgi?id=1429
I would still like to build statically with this option. I mean, I can just manually edit sdl2-config but I want to understand why you removed it.
As per the bug report I don’t understand how --libs could be affected by this. But then I hardly understand everything around code :slight_smile:

Also you might need to change docs/README-macosx.md accordingly.

And Cocoa only. No carbon anymore.

Joseph

It’s set somewhere else in configure.in these days, as the carbon framework is still needed (SDL_cocoakeyboards.m and SDL_cocoamodes.m).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org