Probably a very basic problem

I’ve been unable to do anything with SDL. I’m trying to compile a very basic
programme, simply initialising things:

#include “include\SDL.h” /* All SDL App’s need this */
#include
#include <stdlib.h>

int main() {

printf("Initializing SDL.\n");

/* Initialize defaults, Video and Audio */
if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { 
    printf("Could not initialize SDL: %s.\n", SDL_GetError());
    exit(-1);
}

printf("SDL initialized.\n");

printf("Quiting SDL.\n");

/* Shutdown all subsystems */
SDL_Quit();

printf("Quiting....\n");

exit(0);

}

As you can see, it is one of the examples from the documentation (complete
with spelling errors). The problem is that it won’t compile. I get the
following error messages from both djgpp and Borland’s bcc32:

undefined reference to 'SDL_Init’
undefined reference to 'SDL_GetError’
undefined reference to ‘SDL_Quit’

They are found in files in the src directory - how can I get my compiler to
find them? I’ve tried playing with the system path to no avail. I’ve
specified sdl.c with an #include line, but it #includes sdl.h which it can’t
find. I’ve copied sdl.c to the \include directory, and found that there
are other source files linked that need to be moved, and so on…

What am I missing? Are all the source files supposed to be in the \include
directory? If so, why aren’t they there already? And why do the examples
#include sdl.h when it is sdl.c that needs linking?

Thanks.

squigger

My home page - http://www.hotkey.net.au/~jasonjob

Utter damnation upon, those who mangle and misuse comma’s and, apostrophes’

I’ve been unable to do anything with SDL. I’m trying to compile a very basic
programme, simply initialising things:

#include “include\SDL.h” /* All SDL App’s need this */

This should be “#include “SDL.h””

> As you can see, it is one of the examples from the documentation (complete > with spelling errors). The problem is that it won't compile. I get the > following error messages from both djgpp and Borland's bcc32: > > undefined reference to 'SDL_Init' > undefined reference to 'SDL_GetError' > undefined reference to 'SDL_Quit'

Are you linking against the libraries?
Under Linux, I do:

gcc foo.o -o foo sdl-config --libs

Running “sdl-config --libs” gives me, on my Linux box:

-L/usr/lib -lSDL -lpthread

Pretty simple.

shrug

-bill!On Sat, Mar 22, 2003 at 11:13:09AM +1100, squigger wrote:

At 05:34 PM 21/03/2003 -0800, you wrote:

I’ve been unable to do anything with SDL. I’m trying to compile a very
basic

programme, simply initialising things:

#include “include\SDL.h” /* All SDL App’s need this */

This should be “#include “SDL.h””

> As you can see, it is one of the examples from the documentation (complete > with spelling errors). The problem is that it won't compile. I get the > following error messages from both djgpp and Borland's bcc32: > > undefined reference to 'SDL_Init' > undefined reference to 'SDL_GetError' > undefined reference to 'SDL_Quit'

Are you linking against the libraries?
Under Linux, I do:

gcc foo.o -o foo sdl-config --libs

Running “sdl-config --libs” gives me, on my Linux box:

-L/usr/lib -lSDL -lpthread

Pretty simple.

Sorry, should have mentioned it - I’m using windows.

squigger

My home page - http://www.hotkey.net.au/~jasonjob

Utter damnation upon, those who mangle and misuse comma’s and, apostrophes’>On Sat, Mar 22, 2003 at 11:13:09AM +1100, squigger wrote:

At 05:34 PM 21/03/2003 -0800, you wrote:

I’ve been unable to do anything with SDL. I’m trying to compile a
very
basic

programme, simply initialising things:

#include “include\SDL.h” /* All SDL App’s need this */

This should be “#include “SDL.h””

> As you can see, it is one of the examples from the documentation (complete> with spelling errors). The problem is that it won't compile. I get the> following error messages from both djgpp and Borland's bcc32:> > undefined reference to 'SDL_Init' > undefined reference to 'SDL_GetError' > undefined reference to 'SDL_Quit'

Are you linking against the libraries?
Under Linux, I do:

gcc foo.o -o foo sdl-config --libs

Running “sdl-config --libs” gives me, on my Linux box:

-L/usr/lib -lSDL -lpthread

Pretty simple.

Sorry, should have mentioned it - I’m using windows.

Issue “bcc32” on its own to get command-line help. More info in the
helpfiles of course. If it’s Builder IDE then…
[Project]->[Options]->[Directories/Conditionals]->[Include path]
…and browse to wherever all the *.h sdl header files are gonna reside.
Ditto for [Library path] just below, but browse for the path
holding the sdl *.lib’s. That done, use the “add to project” menu entry
and select the actual *.libs that the linker needs to resolve those
’undefined reference’ errors.

bcc32 has two *.cfg files in its “Bin” folder, ie where bcc32.exe is
sat. One controls the compiler, the other the linker. Example minimum
for the freecommandline compiler…

Create/Edit $(BCB)\Bin\bcc32.cfg and adjust accordingly
-I"c:\app\b55\Include"
-L"c:\app\b55\Lib"

Create/Edit $(BCB)\Bin\ilink32.cfg and adjust accordingly
-L"c:\app\b55\Lib"

…if it’s Builder and they already exist then don’t remove what’s
there, just append to them if necessary. In either case you can plonk
the sdl stuff here. The advantage is the command line driven compiler of
each will always know where sdl is. The disadvantage is you may not
really want this - but assuming you do, you might end up with…

bcc32.cfg
-I"c:\app\b55\Include;c:\app\b55\Include\SDL"
-L"c:\app\b55\Lib;c:\app\b55\Lib\SDL"

ilink32.cfg
-L"c:\app\b55\Lib;c:\app\b55\Lib\SDL"

You’d put all the sdl headers (.h) into “c:\app\b55\Include\SDL” and
all your sdl libs (
.lib) into “c:\app\b55\Lib\SDL”. It’ll now compile,
because it can see the headers, and link, because it can see the libs.

You don’t have to edit the *.cfg files. You can use the “-I” switch to
add the sdl header path manually - either on the command line or, more
usually, within a makefile. Ditto the lib path via “-L”.

The above assumes you have downloaded a precompiled sdl. It’ll have
*.lib and *.dll with it. Defer to the instructions within its README.
Building the DLL yourself from source isn’t hard but it has absolutely
nothing to do with sdl: ie you go about it exactly the same as any other
DLL.On Sun, 23 Mar 2003 09:06:14 +1100 squigger wrote:

On Sat, Mar 22, 2003 at 11:13:09AM +1100, squigger wrote:


Guy Harrison
@Guy_Harrison