 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
tobiasbp
Joined: 22 Apr 2006 Posts: 5 Location: Denmark
|
Posted: Mon Apr 24, 2006 7:17 am Post subject: SDL - How to disable SDL_main? |
|
|
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 |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Mon Apr 24, 2006 7:46 am Post subject: Re: SDL - How to disable SDL_main? |
|
|
| 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? |
I would recommend that you use "sed" inside the Makefile to remove the parts of sdl-config that you don't want, like this:
| Code: |
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags | sed s/-Dmain=SDL_main//)
LIBS += $(shell $(PSPBIN)/sdl-config --libs | sed s/-lSDLmain//)
|
If you do this, your "main" becomes the actual main function, and libSDLmain.a will not be used. |
|
| Back to top |
|
 |
tobiasbp
Joined: 22 Apr 2006 Posts: 5 Location: Denmark
|
Posted: Mon Apr 24, 2006 11:47 pm Post subject: |
|
|
I never did make the disabling of SDL_main work. I commented out the PSP specific setup commands in my C file and things appear to be working.
Thanks for your help. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|