Mandrake Linking problem

I would be grateful if somebody could help me with my
problem. I have Mandrake 10.1, downloaded SDL 1.2.9,
installed it and with this little program:

#include <stdio.h>
#include <SDL/SDL.h>

int main( int arc, char* argv[] )
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”,
SDL_GetError());
exit(1);
}
else
printf( “SDL initialized sucesfully!!!\n” );

return 0;
}

THIS HAPPENS:

gcc -o mali mali.c
/home/berislav/tmp/ccZdHbHf.o(.text+0x22): In function
main': : undefined reference toSDL_Init’
/home/berislav/tmp/ccZdHbHf.o(.text+0x34): In function
main': : undefined reference toSDL_GetError’
collect2: ld returned 1 exit status

So, it seems to me that implementation of the calling
functions was not found.

Responses to command from FAQs are as follows:

which sdl-config
/usr/bin/sdl-config

sdl-config --version
1.2.9

locate libSDL
/usr/share/doc/libSDL1.2-1.2.7
/usr/share/doc/libSDL1.2-1.2.7/README-SDL.txt
/usr/share/doc/libSDL1.2-1.2.7/BUGS
/usr/share/doc/libSDL1.2-1.2.7/COPYING
/usr/share/doc/libSDL1.2-1.2.7/CREDITS
/usr/share/doc/libSDL_image1.2-1.2.3
/usr/share/doc/libSDL_image1.2-1.2.3/COPYING
/usr/lib/libSDL-1.2.so.0.7.0
/usr/lib/libSDL-1.2.so.0
/usr/lib/libSDL_image-1.2.so.0.1.2
/usr/lib/libSDL_image-1.2.so.0
/usr/lib/libSDLmain.a
/usr/lib/libSDL.a
/usr/lib/libSDL.la

tail config.log
tail: cannot open `config.log’ for reading: No such
file or directory

Thank you,
Berislav
Croatia (Europe)__________________________________________
Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com

Berislav Vidakovic wrote:

gcc -o mali mali.c
You need to link against SDL to use it.
gcc sdl-config --cflags sdl-config --libs -o mali mali.c
The functions are defined inside the library, but if you don’t link
against it, the linker can’t find them. Hope that helps.

Hello there,

You forgot to feed the SDL library to the linker!! Instead of:

gcc -o mali mali.c

You should had

gcc -o mali mali.c sdl-config --cflags --libs

Or, you might want to compile to objects code before linkage:

gcc -c mali.c sdl-config --cflags
gcc -o mali mali.o sdl-config --libs

You should also change this include in your code:

#include <SDL/SDL.h>
It should be red as:
#include <SDL.h>

I’ve made a simple game in SDL for begginners, it is called Bouncing and you
can find it here:
http://rpmcruz.planetaclix.pt/repository/graphical/#bouncing
(it has both SDL and Allegro code. Go to sdl/ for SDL.)

It also has a Makefile that you may copy, edit the SRC, and use it in your
game. In case you need further assistance, feel free to contact me privately
(to avoid annoying the rest of the guys).

Cheers,
RicardoEm S?bado 03 Dezembro 2005 00:08, o Berislav Vidakovic escreveu:

I would be grateful if somebody could help me with my
problem. I have Mandrake 10.1, downloaded SDL 1.2.9,
installed it and with this little program:

#include <stdio.h>
#include <SDL/SDL.h>

int main( int arc, char* argv[] )
{
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, “Unable to init SDL: %s\n”,
SDL_GetError());
exit(1);
}
else
printf( “SDL initialized sucesfully!!!\n” );

return 0;
}

THIS HAPPENS:

gcc -o mali mali.c
/home/berislav/tmp/ccZdHbHf.o(.text+0x22): In function

main': : undefined reference toSDL_Init’

/home/berislav/tmp/ccZdHbHf.o(.text+0x34): In function

main': : undefined reference toSDL_GetError’

collect2: ld returned 1 exit status

So, it seems to me that implementation of the calling
functions was not found.

Responses to command from FAQs are as follows:

which sdl-config
/usr/bin/sdl-config

sdl-config --version
1.2.9

locate libSDL
/usr/share/doc/libSDL1.2-1.2.7
/usr/share/doc/libSDL1.2-1.2.7/README-SDL.txt
/usr/share/doc/libSDL1.2-1.2.7/BUGS
/usr/share/doc/libSDL1.2-1.2.7/COPYING
/usr/share/doc/libSDL1.2-1.2.7/CREDITS
/usr/share/doc/libSDL_image1.2-1.2.3
/usr/share/doc/libSDL_image1.2-1.2.3/COPYING
/usr/lib/libSDL-1.2.so.0.7.0
/usr/lib/libSDL-1.2.so.0
/usr/lib/libSDL_image-1.2.so.0.1.2
/usr/lib/libSDL_image-1.2.so.0
/usr/lib/libSDLmain.a
/usr/lib/libSDL.a
/usr/lib/libSDL.la

tail config.log
tail: cannot open `config.log’ for reading: No such
file or directory

Thank you,
Berislav
Croatia (Europe)


"… the Mayo Clinic, named after its founder, Dr. Ted Clinic …"
– Dave Barry

Pete Elmore wrote:

gcc sdl-config --cflags sdl-config --libs -o mali mali.c

Note that you can just do

gcc sdl-config --cflags --libs -o mali mali.c

regards,
Graue

Or make a proper Makefile :^)

SDL_LIBS=sdl-config --libs
SDL_CFLAGS=sdl-config --cflags

CFLAGS=$(SDL_CFLAGS) # and whatever else you need, e.g., -O2 -Wall
LIBS=$(SDL_LIBS) # and whatever else you need, e.g., -lm or what have you

all: program

clean:
-rm program
-rm program.o

program: program.o
$(CC) -o program program.o $(CFLAGS) $(SDL_LIBS)

program.o: program.c
$(CC) program.c -o program.o # <-- this is actually implied, so
# can be removed in sane environs.

Oh, and then type:

make

;)On Fri, Dec 02, 2005 at 08:53:55PM -0500, Catatonic Porpoise wrote:

Note that you can just do

gcc sdl-config --cflags --libs -o mali mali.c


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/

Nope. Same happens :frowning:

— Pete Elmore wrote:> Berislav Vidakovic wrote:

gcc -o mali mali.c
You need to link against SDL to use it.
gcc sdl-config --cflags sdl-config --libs -o
mali mali.c
The functions are defined inside the library, but if
you don’t link
against it, the linker can’t find them. Hope that
helps.


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


Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com

Hello,

Man, you’re probably mispelling the command. Notice that the character ` is
not the English astroph ’ – it is the grave accent!

gcc -o mali mali.c sdl-config --cflags --libs

Just copy and past it into the terminal. Works?

Cheers,
RicardoEm S?bado 03 Dezembro 2005 09:12, o Berislav Vidakovic escreveu:

Nope. Same happens :frowning:

— Pete Elmore wrote:

Berislav Vidakovic wrote:

gcc -o mali mali.c

You need to link against SDL to use it.
gcc sdl-config --cflags sdl-config --libs -o
mali mali.c
The functions are defined inside the library, but if
you don’t link
against it, the linker can’t find them. Hope that
helps.


“What’s the use of a good quotation if you can’t change it?”
– The Doctor

Ricardo Cruz wrote:

Man, you’re probably mispelling the command. Notice that the character ` is
not the English astroph ’ – it is the grave accent!

gcc -o mali mali.c sdl-config --cflags --libs

That’s why the preferred syntax is

gcc -o mali mali.c $(sdl-config --cflags --libs)

August

That depends on your shell though.
csh/tcsh doesn’t recognise that syntax.

If the OP is still having problems, try just running:
sdl-config --cflags --libs
at a prompt, and see what it outputs.

Julian.On Sunday 04 December 2005 5:17 pm, August Karlstrom wrote:

Ricardo Cruz wrote:

Man, you’re probably mispelling the command. Notice that the
character ` is not the English astroph ’ – it is the grave accent!

gcc -o mali mali.c sdl-config --cflags --libs

That’s why the preferred syntax is

gcc -o mali mali.c $(sdl-config --cflags --libs)


“In the fight between you and the world, back the world.”
–Frank Zappa