Beginner Compilation Errors

Hi all,

I’m unable to compile the simplest SDL program. I’ve provided the program
and gcc output below (I’m using RHL7.1).
Any help will be great.

Thanks
Russ.=================================
Program:

[root at localhost sdl_first]# cat sdltest.c

#include <stdio.h>
#include <stdlib.h>
#include “/usr/include/SDL/SDL.h”

int main () {
printf(“Initializing SDL…\n”)

if ((SDL_Init(SDL_INIT_VIDEO) < 0)) {
printf(“Could not initialize SDL.\n”);
exit(1);
}
printf(“SDL initialized.\n”);

exit(0);
}
[root at localhost sdl_first]#

==================================
Result:

[root at localhost sdl_first]# gcc -Wall -c sdltest.c -o sdltest.o
[root at localhost sdl_first]#

[root at localhost sdl_first]# gcc sdltest.o -o sdltest -L/usr/lib -lSDL
/usr/lib/libSDL.so: undefined reference to pthread_create' /usr/lib/libSDL.so: undefined reference topthread_cancel’
/usr/lib/libSDL.so: undefined reference to sem_destroy' /usr/lib/libSDL.so: undefined reference tosem_wait’
/usr/lib/libSDL.so: undefined reference to sem_post' /usr/lib/libSDL.so: undefined reference topthread_mutexattr_setkind_np’
/usr/lib/libSDL.so: undefined reference to sem_init' /usr/lib/libSDL.so: undefined reference topthread_sigmask’
/usr/lib/libSDL.so: undefined reference to sem_trywait' /usr/lib/libSDL.so: undefined reference topthread_mutexattr_init’
/usr/lib/libSDL.so: undefined reference to sem_getvalue' /usr/lib/libSDL.so: undefined reference topthread_join’
/usr/lib/libSDL.so: undefined reference to `pthread_cond_timedwait’
collect2: ld returned 1 exit status
[root at localhost sdl_first]#

I’m unable to compile the simplest SDL program. I’ve provided the
program and gcc output below (I’m using RHL7.1). Any help will be
great.

[…]

Take a look at the output of ‘sdl-config --libs’ to get an idea of
which other libraries need to be linked in. Alternatively, you can
simply use sdl-config. (gcc sdl-config --libs --cflags …)On 27 May 2001 07:07:52 -0700, russmack at mweb.co.za wrote:

christian zander paranoia, n.: a healthy understanding
zander at hdz.uni-dortmund.de of the way the universe works.

Russel MacKenzie wrote:

Hi all,

I’m unable to compile the simplest SDL program. I’ve provided the program
and gcc output below (I’m using RHL7.1).
Any help will be great.

Thanks
Russ.

/snip/

[root at localhost sdl_first]# gcc -Wall -c sdltest.c -o sdltest.o
[root at localhost sdl_first]# gcc sdltest.o -o sdltest -L/usr/lib -lSDL
As far as I know sdl needs pthread library under linux, so:
gcc sdltest.o -o sdltest -L/usr/lib -lSDL -lpthread
should work better :slight_smile:

                                                        Hope this helps.

[root at localhost sdl_first]# gcc -Wall -c sdltest.c -o sdltest.o
[root at localhost sdl_first]# gcc sdltest.o -o sdltest -L/usr/lib -lSDL

Do this instead:

gcc -Wall -c sdltest.c -o sdltest.o `sdl-config --cflags`
gcc sdltest.o -o sdltest `sdl-config --libs`

(note the quote character is a backtick, and not a single quote mark.)

–ryan.

I don’t understand the output, but it works!

Thanks guys!
Russ> ----- Original Message -----

From: phoenix@minion.de (Christian Zander)
To:
Sent: Sunday, May 27, 2001 4:17 PM
Subject: [SDL] Re: Beginner Compilation Errors

On 27 May 2001 07:07:52 -0700, @Russell_Mackenzie wrote:

I’m unable to compile the simplest SDL program. I’ve provided the
program and gcc output below (I’m using RHL7.1). Any help will be
great.

[…]

Take a look at the output of ‘sdl-config --libs’ to get an idea of
which other libraries need to be linked in. Alternatively, you can
simply use sdl-config. (gcc sdl-config --libs --cflags …)

christian zander paranoia, n.: a healthy understanding
zander at hdz.uni-dortmund.de of the way the universe works.

hi,
Sorry to truoble U all.
I got it solved by myself.The problem is with compilation itself.
everyours
S.Praveen Kumar