Compiling whoes - need a hint

Hi,

This is more a general compile question.
I hope the knowledgeable folks here will be so kind to
give me a hint, helping me to compile a SDL application
staticly on Linux (powerpc).

I tried to compile a SDL game statically
on stable (sarge) GNU Debian PowerPC Linux.

1st try:
SDL on Debian seems to be linked with lib ascii art.
Linking of libaa failed with undefined references of libaa.a
to some gpm functions. I installed libgpm.a and added -lgpm to the
compile options but still the compile failed.

2nd try:
Then, I thought maybe compiling SDL from scratch would be a better
solution. Downloaded SDL - did configure, make, make install.
Again linking of the game fails with an undefined reference.
libXrender.a has an undefined refrence to XNextRequest.

Can someone please help me and tell me where XNextRequest is defined?

Many thanks in advance
Gunnar

Gunnar von Boehn wrote:

Hi,

This is more a general compile question.
I hope the knowledgeable folks here will be so kind to
give me a hint, helping me to compile a SDL application
staticly on Linux (powerpc).

Why static?

I tried to compile a SDL game statically
on stable (sarge) GNU Debian PowerPC Linux.

If you want to do things like this, my first advice would be to remove
the debian packaged version, and build your own so you know exactly
how it is built.

Pete.

Hi Peter,

This is more a general compile question.
I hope the knowledgeable folks here will be so kind to
give me a hint, helping me to compile a SDL application
staticly on Linux (powerpc).

Why static?

Because I want to guarantee that the application
is able to work out of the box for the user.
Without the need to install many libs like:
libvorbis, libsdl, libtheora etc.
Makes sense doesn’t it?

I tried to compile a SDL game statically
on stable (sarge) GNU Debian PowerPC Linux.

If you want to do things like this, my first advice would be to remove
the debian packaged version, and build your own so you know exactly
how it is built.

Makes sense.
I assume after compiling SDL I can use ldd to see which libs it depends
and use ldd again on those libs and so on and so forth.

After looking at all the libs I should find the one the provides
XNextRequest.

Cheers
Gunnar

Hi Everybody,

I still can not find where “XNextRequest” is defined.
I’m statically linking my SDL app and SDL.a comes up
with an undefined reference to XNextRequest.

I’m linking the app against everything that ldd tells me libsdl is
linked against but still the “XNextRequest”.

Can someone peb so nice to give me a hint, please?

Cheers
Gunnar

Gunnar von Boehn wrote:

Because I want to guarantee that the application
is able to work out of the box for the user.
Without the need to install many libs like:
libvorbis, libsdl, libtheora etc.
Makes sense doesn’t it?

In my opinion the best way to do this is to make your exe look in the
current folder for the libs, and bundle the libs with your exe. That
way, should there be a bugfix for SDL etc the user can apply it without
having to rebuild your exe (assuming it’s open source). If the user
feels that using his distro’s version is better, they can delete the
bundled copies and the exe will automatically use the system installed ones.

There are switches you can feed to the linker which make it add library
search paths into the executable, but I can’t remember what they are
offhand.

Makes sense.
I assume after compiling SDL I can use ldd to see which libs it depends
and use ldd again on those libs and so on and so forth.

Sure.

After looking at all the libs I should find the one the provides
XNextRequest.

At a guess it’s some X11 lib. You won’t want to statically link that !

I am guessing that what you’re doing here is passing -static to gcc at
the link stage, which will then want to link EVERYTHING statically. This
is a total pain. What you will need to do is use -Wl,-static and
-Wl,-dynamic to link some libs statically, and others (like X11)
dynamically.

Pete.

Thanks for your hints - but I still need some help.

My Status:
I’m compiling a commercial game for PowerPC Linux.
The game uses SDL.

  • The dynamic compiled version of the game runs fine.

  • I’m afraid to ship a dynamic game version as I fear that it will not
    work at the users place.

  • Somehow the static compiles segfault on some machines.

Reason is why I fear to ship dynamic builds:
The game uses a number of libs: SDL, vorbis, theora, ogg.
And I have noticed that some (newer) versions of libSDL
create GFX errors in the game. I have not yet analysed this one, but it
looks like one column is blitted to much. Could be a clipping issue.
Because of this I thought compiling the game as static
is the way to guarantee that the game always works.

Maybe another idea is better?
Maybe adding of the libs into ther game folder might work if I figure
how to change the library path.

My big und confusing problem is that the static game version
runs on two test machines but segfaults on the machine where I have
builded it.

Can someone explain this?

I noticed that the static game does a lot of fopen
on libs, it looks like it wants to load them.
This puzzles me.
I would have thought that all the libs are compiled in
and that it does not need to fopen them on disk anymore.

Can someone explain this?

Do I need to build SDL in some special way?
Currently I just did a ./configure as I was
not sure what feature I can savely disable in SDL.

Here is my compile line maybe someone want to comment:
g++ -o robin libgame.a -static -L. -ljpg -lsbng ‘sdl-config
–static-libs’ ‘freetype-config -libs’ -ltheora -lvorbis -logg -lSDL
-L/usr/X11R6/lib -lX11

I tried as well only including SDL and theora and vorbis
by using -WL,-Bstatic … and -WL,-Bdynamic
so that X11 and the other libs are used dynamicly.
But this version still segfaults on my buildmachine.

Many in advance thanks for your help!!!

Gunnar

Peter Mulholland wrote:> Gunnar von Boehn wrote:

Because I want to guarantee that the application
is able to work out of the box for the user.
Without the need to install many libs like:
libvorbis, libsdl, libtheora etc.
Makes sense doesn’t it?

In my opinion the best way to do this is to make your exe look in the
current folder for the libs, and bundle the libs with your exe. That
way, should there be a bugfix for SDL etc the user can apply it without
having to rebuild your exe (assuming it’s open source). If the user
feels that using his distro’s version is better, they can delete the
bundled copies and the exe will automatically use the system installed ones.

There are switches you can feed to the linker which make it add library
search paths into the executable, but I can’t remember what they are
offhand.

Makes sense.
I assume after compiling SDL I can use ldd to see which libs it depends
and use ldd again on those libs and so on and so forth.

Sure.

After looking at all the libs I should find the one the provides
XNextRequest.

At a guess it’s some X11 lib. You won’t want to statically link that !

I am guessing that what you’re doing here is passing -static to gcc at
the link stage, which will then want to link EVERYTHING statically. This
is a total pain. What you will need to do is use -Wl,-static and
-Wl,-dynamic to link some libs statically, and others (like X11)
dynamically.

Pete.


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