Hello....
I want to add sound to my C game using SDL. I have installed SDL and SDL_mixer.
As I allready have my program written with the PSPSDK callbacks I dont want SDL to add those to my main().
I dont really understand the documentation (shown at end of post).
It says:
"Of course, you can leave off -lSDLmain, and write the real main()
yourself if you need more control than this."
I have not added -lSDLmain to my libs. So according to the above it should be off right? It's not however.
The documentation then says:
"By default, the PSP "sdl-config --cflags" will define main=SDL_main."
Does that mean I have to change the sdl-config script to disable main=SDL_main?
Here is my Makefile:
TARGET = tileDraw
OBJS = main.o graphics.o framebuffer.o
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lSDL_mixer
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Image Example
PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
include $(PSPSDK)/lib/build.mak
From the SDL documentation:
SDL_main
--------
When writing an SDL program, the typical use is to write your main
function as "SDL_main", then link -lSDLmain which provides the real
main(). In this implementation, -lSDLmain will:
- Define the required PSP_* macros
- Set up the "home" button callback.
- Initialize the debugging screen
- Call the user-supplied SDL_main
- When it returns, delay 2.5 seconds, then exit to VSH.
Of course, you can leave off -lSDLmain, and write the real main()
yourself if you need more control than this.
By default, the PSP "sdl-config --cflags" will define main=SDL_main.
Building applications
---------------------
Write your source file as you would a normal SDL program. Use the standard
Makefile as supplied with any PSPSDK sample program. Above the final "include"
line, add:
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
Thanks
SDL - How to disable SDL_main?
Re: SDL - How to disable SDL_main?
I would recommend that you use "sed" inside the Makefile to remove the parts of sdl-config that you don't want, like this:tobiasbp wrote:The documentation then says:
"By default, the PSP "sdl-config --cflags" will define main=SDL_main."
Does that mean I have to change the sdl-config script to disable main=SDL_main?
Code: Select all
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)