Config & Setup

Hello everyone,

I’m trying to get SDL correctly configured on my linux machine. It
seems I’ve done everything right for the configure; make; make install
routine. I’ve even built the demos under the test/ subdir and they run
fine. However, I encounter a problem when i try to compile some of the
test scripts myself from the command line. I’m using a recent version
of gcc and I’m trying to compile a test script taken from the examples
on the SDL site. I;ve copied the script from the following URL into a
file called ‘samlpe.c’, but when i try to run it i get errors.

http://www.libsdl.org/intro/usinginit.html

I try to run this:

gcc ./sample.c

but end up with this:
./sample.c:2: SDL.h: No such file or directory

So i changed #include “SDL.h” to represent the fully qualified path to
SDL.h and I get this error:

/tmp/ccoDIhFt.o: In function ‘main’:
/tmp/ccoDIhFt.o(.text+0x6): undefined reference to ‘SDL_Init’
/tmp/ccoDIhFt.o(.text+0x14): undefined reference to ‘SDL_GetError’
/tmp/ccoDIhFt.o(.text+0x39): undefined reference to ‘SDL_Quit’

I have put this path in both my $PATH & $LD_LIBRARY_PATH env variables

(sdl_home)/include/SDL/

What more do i need to do? What are the steps to correctly use SDL
after configure, make, make install ?

try:
gcc -o sample sample.c sdl-config --cflags sdl-config --libs

sdl-config with its various parameters spits out all the right include
and library paths as well as the -l library directives for linking
that you need to compile an SDL app.

And to answer your q about the undefined references, its because you
need to tell the compiler what libraries you want to link with (eg use
the flag -lSDL), but the sdl-config program above will take care of that
for you.

Cheers,

Julian.On Sat, 9 Sep 2000, mark kimsal wrote:

I try to run this:

gcc ./sample.c

I figured since this is the most used crossplatform library this would
be the appropriate list to post on. I am doing a research project on
designing and developing crossplatform games for linux/windows and other
OS’s for a college project. I was wondering if anyone knew any useful
sites or other sources of information on crossplatform game design.
Companies say that creating crossplatform games is too costly and not
worth the investment but we wish to prove otherwise.

http://www.mongeese.org

Companies say that creating crossplatform games is too costly and not
worth the investment but we wish to prove otherwise.

In my experience it’s not the coding that is too costly, it’s the testing
and support that is costly. It’s also tough to write good cross-platform
games if you don’t have any cross-platform experience.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I figured since this is the most used crossplatform library this would
be the appropriate list to post on. I am doing a research project on
designing and developing crossplatform games for linux/windows and other
OS’s for a college project. I was wondering if anyone knew any useful
sites or other sources of information on crossplatform game design.
Companies say that creating crossplatform games is too costly and not
worth the investment but we wish to prove otherwise.

WHen I stick to ANSI C and plain SDL, my games are amazingly portable.
People have taken what I’ve written under Linux and gotten them compiled
and running under BeOS and MacOS. I’ve also used my Linux system to
ccross-compile Windows binaries, and it’s pretty easy, too. :slight_smile:

Of course, I write games in the style of old Atari 2600 cartridges,
not Doom/Quake. :slight_smile:

-bill!

Wow thanks, that worked …sort of. I can’t type that exact command, I have to
run sdl-config --cflags and then type the output to the console. But I’ve
circumvented all of that by making simple shell scripts. Now here’s my other
problem. I’m trying to get SDL to work with java. I’m doing native code
compilation with gjc 2.96. What I’m doing is making a simple function out of
the sample that i got to work, then calling it from a java class. Everything
seems to go fine but when i run the linked file it only says
"Segmentation fault"

I’m wondering if there is any way to dig up more information about the segfault
or if anyone magically knows what is going wrong already.On Sat, 09 Sep 2000, you wrote:

On Sat, 9 Sep 2000, mark kimsal wrote:

I try to run this:

gcc ./sample.c

try:
gcc -o sample sample.c sdl-config --cflags sdl-config --libs

sdl-config with its various parameters spits out all the right include
and library paths as well as the -l library directives for linking
that you need to compile an SDL app.

And to answer your q about the undefined references, its because you
need to tell the compiler what libraries you want to link with (eg use
the flag -lSDL), but the sdl-config program above will take care of that
for you.

Cheers,

Julian.

I try to run this:

gcc ./sample.c

try:
gcc -o sample sample.c sdl-config --cflags sdl-config --libs

sdl-config with its various parameters spits out all the right include
and library paths as well as the -l library directives for linking
that you need to compile an SDL app.

And to answer your q about the undefined references, its because you
need to tell the compiler what libraries you want to link with (eg use
the flag -lSDL), but the sdl-config program above will take care of that
for you.

Cheers,

Julian.

Wow thanks, that worked …sort of. I can’t type that exact command, I have to
run sdl-config --cflags and then type the output to the console. But I’ve
circumvented all of that by making simple shell scripts.

The trick is in the quote marks. If you use backquotes (the key beside
1), the command will be executed, and the result will be substitued.

Also consider taking a look at “make”.

Now here’s my other problem. I’m trying to get SDL to work with java.
I’m doing native code compilation with gjc 2.96. What I’m doing is
making a simple function out of the sample that i got to work, then
calling it from a java class. Everything seems to go fine but when i
run the linked file it only says “Segmentation fault”

I’m wondering if there is any way to dig up more information about the
segfault or if anyone magically knows what is going wrong already.

I’m sorry, I don’t know too much about Java’s interface with other
code (I’ve even forgotten the TLA =), or even if you need it in
this case)

To see in what function the program segfaults though, you can type:
gdb -c core
(assuming it dumped core)

HTH

Julian.On Mon, 11 Sep 2000, M K wrote:

On Sat, 09 Sep 2000, you wrote:

On Sat, 9 Sep 2000, mark kimsal wrote:

I figured out how to natively compile a java program that is linked to SDL via
CNI. The flag ‘-lpthread’ must be left out of the linker flags during the
linking step. What does this flag do? Will not using it impose any
limitations? And finally, has anyone attempted/saw a use in making a java
binding for SDL? Note that i’m using Cygnus Native Interface not JNI, so the
end program must be natively compiled.> On Sat, 9 Sep 2000, mark kimsal wrote:

I try to run this:

gcc ./sample.c

try:
gcc -o sample sample.c sdl-config --cflags sdl-config --libs

sdl-config with its various parameters spits out all the right include
and library paths as well as the -l library directives for linking
that you need to compile an SDL app.

And to answer your q about the undefined references, its because you
need to tell the compiler what libraries you want to link with (eg use
the flag -lSDL), but the sdl-config program above will take care of that
for you.

Cheers,

Julian.

M K wrote:

I figured out how to natively compile a java program that is linked to SDL via
CNI. The flag ‘-lpthread’ must be left out of the linker flags during the
linking step. What does this flag do? Will not using it impose any
limitations? And finally, has anyone attempted/saw a use in making a java
binding for SDL? Note that i’m using Cygnus Native Interface not JNI, so the
end program must be natively compiled.

Could you create a minimal example of this a post it to the java-discuss
list?

http://sources.redhat.com/java/mail.html

Mo DeJong
Red Hat Inc

Could you create a minimal example of this a post it to the java-discuss
list?

And can you feed the useful bits back to this list? :slight_smile:

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

Mo wrote:

M K wrote:

I figured out how to natively compile a java program that is linked to SDL via
CNI. The flag ‘-lpthread’ must be left out of the linker flags during the
linking step. What does this flag do? Will not using it impose any
limitations? And finally, has anyone attempted/saw a use in making a java
binding for SDL? Note that i’m using Cygnus Native Interface not JNI, so the
end program must be natively compiled.

Could you create a minimal example of this a post it to the java-discuss
list?

If you are on the java-discuss list then you probably now know what I just found
out.
removing -lpthreads will not allow you to use threads in your java program. I think

I will hold off on posting how to do it untill i can do it correctly. This might be
a
GCJ bug, I don’t know yet.