🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Compiling SDL

Started by
10 comments, last by Vetinari 23 years ago
I am entering into the world of linux programming, and I decided to test out the SDL. Unfortunetly I am having problems compiling. Here is my makefile:
quote: Makefile SDL_CFLAGS := $(shell sdl-config --cflags) SDL_LDFLAGS := $(shell sdl-config --libs) CFLAGS = $(SDL_CFLAGS) LDFLAGS = $(SDL_LDFLAGS) myapp: test.o gcc $(LDFLAGS) -o test test.o test.o: test.c gcc $(CFLAGS) -c test.c
and I get the error test.o: Undefined reference to ''SDL_Init'' Thanks for any help, Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
Advertisement
I''ve just started programming on linux and the sdl too.

You shouldn''t name programs test as there''s already a command named that. You won''t have a problem as long as you do ./test and providing you don''t have the current working directory in path but it''s good to be aware of these kind of stuft.

Try running on the shell
sdl-config --libs

you should get something like

-L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSDL -lpthread


check libSDL.so is it in /usr/local/lib or whatever

edit /etc/ld.so.conf
and add the line /usr/local/lib or where ever your libSDL.so is.

Then

cd /usr/local/lib
ldconfig

This is all I know of doing besides making sure libSDL.so points to the right library etc.

Hey,

Firstly I think it would good if you know how to compile at command line try this and see if it compiles :- gcc test.c -o test1 `sdl-config --cflags --libs`

Hello from my world
Thanks for the replies guys.

I have the file libSDL.so in /usr/lib, but ldconfig claims it isn't there. When I do a ls libSDL* , libSDL.so is bordered in red and blinking (I think this may be a bad sign). Anyone know what this means?


Mike

Edited by - Vetinari on June 19, 2001 7:52:55 PM
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
Perhaps it''s a way of saying the file is linked to
a invalid location. Reminds me of that common
c bug though my terminal isn''t so colorful so I have
never seen it blink at me before. Try
doing ls -l libSDL.so you should get something like

libSDL.so-> ...

or cat libSDL.so is another way but will probably
mess up your terminal.

and make sure that it''s
linked to the write location.

This shouldn''t have happended as the install is suppose to do it
for you I think. After this I would try reinstalling SDL again.
If this doesn''t work ask the question on the SDL user mailing
list.
OK, thanks, here is what I did. I renamed the actual library file as ''libSDL.so'', and it worked. I tried reloading the library at least 20 times over a few days, and it never worked out. Any ideas why the symbolic link wouldn''t point in the right place?


Mike
"Unintentional death of one civilian by the US is a tragedy; intentional slaughter of a million by Saddam - a statistic." - Unknown
>> I renamed the actual library file as ''libSDL.so''
Really should use ln -s but if it works it works.
So everything works so like does this run ignoring
any small mistakes in it


#include
#include
#include
int main(void)
{
SDL_Surface* screen;

if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}

screen = SDL_SetVideoMode(640, 480, 16, SDL_FULLSCREEN);
if (screen == NULL) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}

/* delay a second */
SDL_Delay(1000);

return 0;
}

During the install portion of SDL''s makefile I think
automatically does it. There''s a chance that maybe it
the Makefile you used to compile the SDL was bad they
really just came up with a new release but I havn''t compiled
mine yet.

I''m new to the SDL and game programming in general
there''s a online book that you can get which shows
you how to use the SDL and a few other libraries.
It''s worth reading if your not used to it some people
say the api is like directx so maybe they can just learn
from the prototypes.

http://mail.lokigames.com/~overcode/plg/
DON''T RUN THIS PROGRAM IT WILL CRASH YOU X SERVER!!

ok just put a atexit(SDL_Quit) in there and the includes
got messed up.
just experimenting to see if I can get the nice
colorcoded code to work



#include
#include
#include

int main(void)
{
SDL_Surface* screen;

if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}

atexit(SDL_Quit);

screen = SDL_SetVideoMode(640, 480, 16, 0);
if (screen == NULL) {
fprintf(stderr, "%s\n", SDL_GetError());
return EXIT_FAILURE;
}

SDL_Delay(1000);

return 0;
}


just experimenting to see if I can get the nice
colorcoded code to work. Ok I took html
tags to seriously I think

  #include <stdio.h>#include <stdlib.h>#include <SDL/SDL.h>int main(void){      SDL_Surface* screen;      if (SDL_Init(SDL_INIT_VIDEO) != 0) {            fprintf(stderr, "%s\n", SDL_GetError());            return EXIT_FAILURE;      }      atexit(SDL_Quit);       screen = SDL_SetVideoMode(640, 480, 16, 0);      if (screen == NULL) {            fprintf(stderr, "%s\n", SDL_GetError());            return EXIT_FAILURE;      }      SDL_Delay(1000);       return 0;}                

This topic is closed to new replies.

Advertisement