I’m not sure if anyone else is experiencing this, but I’m having trouble compiling sdl programs, that seem to compile fine on x86.
$ uname -a
Linux majere.nightshade.org 2.2.14pre9 #82 Tue Nov 30 20:31:09 EST 1999 ppc unknown
For example…
a make in the test/ directory gives me this:
gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o -L/usr
/local/lib -lSDL -lpthread
/usr/bin/ld: warning: libX11.so.6, needed by /usr/local/lib/libSDL.so, not found
(try using --rpath)
/usr/bin/ld: warning: libXext.so.6, needed by /usr/local/lib/libSDL.so, not foun
d (try using --rpath)
/usr/local/lib/libSDL.so: undefined reference to XSetInputFocus' /usr/local/lib/libSDL.so: undefined reference to
XSetWMProtocols’
/usr/local/lib/libSDL.so: undefined reference to XSetWMIconName' /usr/local/lib/libSDL.so: undefined reference to
XShmDetach’
/usr/local/lib/libSDL.so: undefined reference to `XImageByteOrder’
…
[many more error lines, with every X function that SDL uses, I assume]
To fix this, I can add -L/usr/X11R6/lib -lX11 -lXext to my compile line, but shouldn’t this be done somehow automatically? i.e., it’s not my program that’s using libX11/Xext, but libSDL.
Thoughts?
Josh
I’m not sure if anyone else is experiencing this, but I’m having trouble compiling sdl programs, that seem to compile fine on x86.
$ uname -a
Linux majere.nightshade.org 2.2.14pre9 #82 Tue Nov 30 20:31:09 EST 1999 ppc unknown
For example…
a make in the test/ directory gives me this:
gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o -L/usr
/local/lib -lSDL -lpthread
/usr/bin/ld: warning: libX11.so.6, needed by /usr/local/lib/libSDL.so, not found
Wierd, yes, I figured that most platforms would be able to resolve the
dynamic link names, but I guess not. I’ll add them explicitly to the
link line.
Do you have /usr/X11R6/lib in your /etc/ld.so.conf file?
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
Josh Huber wrote:
I’m not sure if anyone else is experiencing this, but I’m having trouble compiling sdl programs, that seem to compile fine on x86.
$ uname -a
Linux majere.nightshade.org 2.2.14pre9 #82 Tue Nov 30 20:31:09 EST 1999 ppc unknown
For example…
a make in the test/ directory gives me this:
gcc -g -O2 -I/usr/local/include -D_REENTRANT -o checkkeys checkkeys.o -L/usr
/local/lib -lSDL -lpthread
/usr/bin/ld: warning: libX11.so.6, needed by /usr/local/lib/libSDL.so, not found
(try using --rpath)
/usr/bin/ld: warning: libXext.so.6, needed by /usr/local/lib/libSDL.so, not foun
d (try using --rpath)
/usr/local/lib/libSDL.so: undefined reference to XSetInputFocus' /usr/local/lib/libSDL.so: undefined reference to
XSetWMProtocols’
/usr/local/lib/libSDL.so: undefined reference to XSetWMIconName' /usr/local/lib/libSDL.so: undefined reference to
XShmDetach’
/usr/local/lib/libSDL.so: undefined reference to `XImageByteOrder’
…
[many more error lines, with every X function that SDL uses, I assume]
To fix this, I can add -L/usr/X11R6/lib -lX11 -lXext to my compile line, but shouldn’t this be done somehow automatically? i.e., it’s not my program that’s using libX11/Xext, but libSDL.
Thoughts?
Josh
Many PPC distro’s don’t link X the same way it is done on x86. Go to your /usr/X11R6/lib directory
and do a nm -a | grep XSetInputFocus and you’ll find it…
Also for example, the function XShmDetach, is in the libXshm or something to that extent. I am currently
writing a cross/architecture/platform game and the primary PPC guy ALWAYS complains about linuxPPC having this issue.
-Alan
http://www.denizengames.com
Note that you MUST specify -lX11 -lXext on the compile line! Didn’t the
manual (and all of the examples and demos) specify this? Your program
uses SDL, and SDL uses X11, so by extension your program uses X11. This
is the way it works in GTK+, Motif, Qt, and EVERY OTHER X TOOLKIT THAT
EXISTS! GTK+ has a script in its configuration that hides these details
from you, called ‘gtk-config’ that, given the appropriate command line
parameters, generates the necessary switches to pass gcc so that a
program using it will compile and link correctly. Maybe we should add a
script like 'sdl-config` to the distro that does a similar thing for
SDL. So you can compile your program by doing something like:
gcc -o myprog myprog.c sdl-config --cflags --libs
which would expand to something like
gcc -o myprog myprog.c -I/usr/local/include/SDL -L/usr/local/lib
-L/usr/X11R6/lib -lSDL -lX11 -lXext -lpthread
and everyone would be happy. And it appears Sam has done this too!–
| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |
College of Engineering, University of the Philippines, Diliman |
Note that you MUST specify -lX11 -lXext on the compile line! Didn’t the
manual (and all of the examples and demos) specify this? Your program
uses SDL, and SDL uses X11, so by extension your program uses X11. This
is the way it works in GTK+, Motif, Qt, and EVERY OTHER X TOOLKIT THAT
EXISTS! GTK+ has a script in its configuration that hides these details
from you, called ‘gtk-config’ that, given the appropriate command line
parameters, generates the necessary switches to pass gcc so that a
program using it will compile and link correctly. Maybe we should add a
script like 'sdl-config` to the distro that does a similar thing for
SDL.
Actually, there is an sdl-config that does this. The problem is that
the dynamic linker automatically handles shared library dependencies
on x86, alpha, sparc, and most versions of ppc linux, but apparently
not all.
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
Sam Lantinga writes:
Wierd, yes, I figured that most platforms would be able to resolve the
dynamic link names, but I guess not. I’ll add them explicitly to the
link line.
well, I’m not convinced that it’s not just an oddity of my installation. It could be a bug with the dynamic linker on ppc. I’m going to post a message about this to the linuxppc-dev list (or the debian one), to see if someone has any thoughts on this…
Do you have /usr/X11R6/lib in your /etc/ld.so.conf file?
Yes, and the libraries that are needed show up with a ldconfig -p
Would adding those libraries explicityly to the link line be a bad Thing™ for some reason?
Josh
Rafael R. Sevilla writes:
Note that you MUST specify -lX11 -lXext on the compile line! Didn’t the
manual (and all of the examples and demos) specify this? Your program
uses SDL, and SDL uses X11, so by extension your program uses X11. This
is the way it works in GTK+, Motif, Qt, and EVERY OTHER X TOOLKIT THAT
EXISTS! GTK+ has a script in its configuration that hides these details
from you, called ‘gtk-config’ that, given the appropriate command line
parameters, generates the necessary switches to pass gcc so that a
program using it will compile and link correctly. Maybe we should add a
script like 'sdl-config` to the distro that does a similar thing for
SDL. So you can compile your program by doing something like:
gcc -o myprog myprog.c sdl-config --cflags --libs
which would expand to something like
gcc -o myprog myprog.c -I/usr/local/include/SDL -L/usr/local/lib
-L/usr/X11R6/lib -lSDL -lX11 -lXext -lpthread
Yes, but what I was saying was that the sdl library loaded libX11 and libXext automatically on X86, but not my my ppc box.
Josh