Inizializing SDL

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

Inizializing SDL

Post by psiko_scweek »

Alright, im trying to code using SDL, ill admit, im just trying to learn these things but whenver I try to use anything from SDL_mixer and SDL_image, it doesnt compile and just has errors...I initialized both using this code:

Code: Select all

	/* Initialize SDL */
	if &#40; SDL_Init&#40;SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK&#41; < 0 &#41; &#123;
		fprintf&#40;stderr, "Couldn't initialize SDL&#58; %s\n",SDL_GetError&#40;&#41;&#41;;
		return EXIT_FAILURE;
	&#125;
and , yeah its still having errors stating..
Undefined Reference to 'IMG_load'
and ect.

how can i verify I set up SDL_image and SDL_mixer properly?

thanks,
psiko
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

oook then.

Post by psiko_scweek »

I realized I forgot to add the libs to the makefile.....

now im getting another error....
error in function IMG_LoadBMP_RW - unspecifed reference to SDL_ReadLE32
and
error in function Mix_Channels - unspecified reference to SDL_mix_audio
and a bunch more...

any ideas?
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

ook...then again!

Post by psiko_scweek »

alright after a bit more tweaking, i realized that its now complaining about OGG files. I thought that if you installed LibTremor you didnt need to install OGG....eh, ill just get em all then right?

any suggestions?
Tinnus
Posts: 67
Joined: Sat Jul 29, 2006 1:12 am

Post by Tinnus »

You have to link your app with -lvorbisidec or something I think.

I've done that to try and play vorbis through SDL_mixer BTW but it simply didn't work. As in, did nothing. Compiled, linked, ran but didn't play the music...

If you get it to work please tell me what you did in the SDL/SDL_mixer/Tremor compiling process :)
Let's see what the PSP reserves... well, I'd say anything is better than Palm OS.
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

gah!!!!

Post by psiko_scweek »

alright i got a majority of it to compile without errors...

but im now im getting a PNG error!!!

here is my Makefile, i think thats where my problem lies.

Code: Select all

TARGET = template
OBJS = main.o

INCDIR = 
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LIBS = -lstdc++ -lc -lSDLmain -lSDL_ttf -lSDL_mixer -lvorbisidec -lSDL_gfx -lSDL_image -lz -lpng -lgl -ljpeg
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Template

PSPBIN = $&#40;PSPSDK&#41;/../bin

CFLAGS += `$&#40;PSPBIN&#41;/sdl-config --cflags`
LIBS += `$&#40;PSPBIN&#41;/sdl-config --libs` 
PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
maybe im doing something wrong?

i followed the directions on this page:

http://feonix.dommel.be/eng%20tuts/translate01.htm

to isntall the SDK and SDL.
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

Post by psiko_scweek »

ok then, i think ive narrowed my problem down to an issue with

SDL_image.

i dont quite know what yet.
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Re: gah!!!!

Post by Wally »

psiko_scweek wrote:alright i got a majority of it to compile without errors...

LIBS = -lstdc++ -lc -lSDLmain -lSDL_ttf -lSDL_mixer -lvorbisidec -lSDL_gfx -lSDL_image -lz -lpng -lgl -ljpeg

to isntall the SDK and SDL.
Would you by any chance have installed libPNG, LibJPG, LIBSDL_TTF, LIB GL?


If not download and install them from svn
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

hmm...

Post by psiko_scweek »

Code: Select all

TARGET = template
PSPSDK = $&#40;shell psp-config --pspsdk-path&#41;
PSPPREFIX = $&#40;shell psp-config --psp-prefix&#41;
PSPBIN = $&#40;PSPPREFIX&#41;/bin
SDL_CONFIG = $&#40;PSPBIN&#41;/sdl-config

OBJS = main.o

DEFAULT_CFLAGS = $&#40;shell $&#40;SDL_CONFIG&#41; --cflags&#41;

MORE_CFLAGS = -g -O2 -fsingle-precision-constant -mno-check-zero-division #-ffast-math

CFLAGS = $&#40;DEFAULT_CFLAGS&#41; $&#40;MORE_CFLAGS&#41;
CXXFLAGS = -fno-exceptions

LIBDIR =
LIBS = -lSDL_mixer -lvorbisidec -lSDL_image -lz -lpng -ljpeg -lSDL_gfx -lm $&#40;shell $&#40;SDL_CONFIG&#41; --libs&#41; 
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Template

include $&#40;PSPSDK&#41;/lib/build.mak
ok, i changed a few things around. Its still not compling. It keeps stating that there are errors with LibPNG.

I have installed all the libs (not too sure about libGL) but everything else Ive installed. I think my problems are stemming from SDL_image.

I installed them all like i said using the website as a basis. Maybe I installed them wrong? is there anyway to un-install them?

lol
psiko
psiko_scweek
Posts: 42
Joined: Sat Nov 12, 2005 2:30 am

lol ok i think i got it

Post by psiko_scweek »

Code: Select all

TARGET = game
PSPSDK = $&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = $&#40;PSPSDK&#41;/../bin

OBJS = main.o

JOY = YES
CFLAGS = -Wall -Wno-long-long -O2 -G0 -DJOY_$&#40;JOY&#41;
CFLAGS += $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags&#41;

LIBS = -lSDL_mixer -lvorbisidec -lSDL_image -lpng -lz -ljpeg $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs&#41; 

EXTRA_TARGETS = EBOOT.PBP

include $&#40;PSPSDK&#41;/lib/build.mak
compliled without problems.
Post Reply