Does Anyone have a sample of SDL being implemented without Project Builder?
I had posted this in another thread, replicated (paraphrased) here at the advisement of an "Elite" board member.
My problem should have a simple solution, that is, to see a working setup of SDL_init without the use of Project Builder in OSX. This project is to be written in C++.
My friend and I are beginning a new project using SDL, which needs to compile and run under both linux, windows, and osx and as such Project Builder seems like an unecessary amount of overhead.
If anyone has a simple two file setup of SDL initialization ( makefile and main.cpp ) That they can share I would be very appreciative.
Please bear in mind that I have been historically of the artistic ilk, and not very experienced with the innards of c++ or make files. Which is why I'm asking here, what I am.
original: thread
Thanks for any assistance,
-thomas
My problem should have a simple solution, that is, to see a working setup of SDL_init without the use of Project Builder in OSX. This project is to be written in C++.
My friend and I are beginning a new project using SDL, which needs to compile and run under both linux, windows, and osx and as such Project Builder seems like an unecessary amount of overhead.
If anyone has a simple two file setup of SDL initialization ( makefile and main.cpp ) That they can share I would be very appreciative.
Please bear in mind that I have been historically of the artistic ilk, and not very experienced with the innards of c++ or make files. Which is why I'm asking here, what I am.
original: thread
Thanks for any assistance,
-thomas
The examples that come with SDL can be built with a Makefile from memory...
I think you'll need the linker flags:
-framework SDL -framework OpenGL -framework Cocoa
at least, and possibly also
-framework Carbon
and/or
-framework QuickTime
I think you'll need the linker flags:
-framework SDL -framework OpenGL -framework Cocoa
at least, and possibly also
-framework Carbon
and/or
-framework QuickTime
Where exactly would the suggested elements go?
I'm assuming the makefile, but I don't know the location within that file, nor am I familiar with the syntax.
Perhaps someone can set up a simple app to init SDL and post what they did to make it work without PB?
I feel like I'm drowning in terminology
Also, I wasn't able to find examples with the SDL source.. strange.
-thomas
I'm assuming the makefile, but I don't know the location within that file, nor am I familiar with the syntax.
Perhaps someone can set up a simple app to init SDL and post what they did to make it work without PB?
I feel like I'm drowning in terminology

Also, I wasn't able to find examples with the SDL source.. strange.
-thomas
I seem to have gotten a bit further along in my process, now I'm at a very interesting stumper.
My makefile looks like:
Posted here in entirety for future help.
My main.cpp includes:
#include "SDL/SDL.h"
#include "SDL/SDL_main.h"
#include "SDL/SDL_opengl.h"
and my main method is prototyped as:
int main(int argc, char * argv[]) {
When I run make, I get:
ld: Undefined symbols:
_main
I plan to edit this post once I figure out a solution to this problem. Hopefully in posterity this will be of some use to someone else.
My makefile looks like:
Posted here in entirety for future help.
Code:
CC = g++
DEBUG =
OPTIZE = -O
LIBS = -lSDL -lobjc
C_FLAGS = -Wall $(DEBUG) $(OPTIZE)
SDL_LIBS = -L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL
UMBRA_FILES = gfxengine.o main.o
umbra: clean $(UMBRA_FILES)
$(CC) $(C_FLAGS) $(UMBRA_FILES) $(LIBS) -o ../umbra
.cpp.o:
$(CC) -c $(C_FLAGS) $<
.c.o:
$(CC) -c $(C_FLAGS) $<
clean:
rm -f *.o
rm -f ../umbraMy main.cpp includes:
#include "SDL/SDL.h"
#include "SDL/SDL_main.h"
#include "SDL/SDL_opengl.h"
and my main method is prototyped as:
int main(int argc, char * argv[]) {
When I run make, I get:
ld: Undefined symbols:
_main
I plan to edit this post once I figure out a solution to this problem. Hopefully in posterity this will be of some use to someone else.
Summarily, it's quite simple, but I learned a bunch of other stuff in the process.
I'm going to post the solution, along with some other interesting factions about makefiles and using sdl with gcc or more specifically g++ as I found out later was the key to my issue.
Firstly, my main.cpp file:
Note the order of includes, initially I had some trouble because I didn't have stdlib included, and then later because it came after the SDL include.
Then my makefile:
This will get you started working with SDL. After this you can browse the fine documentation on the sdl website to provide for setting up a surface, and entering an event loop.
This code won't add nifty items to your menu bar or any of the other things you expect from a regular SDL template Project Builder app, but it will work. You have to force quit this example to get it to stop Cmd+Option+Escape
I really hope someone else finds this useful. If so, please let me know ( I need good news )
-Thomas
I'm going to post the solution, along with some other interesting factions about makefiles and using sdl with gcc or more specifically g++ as I found out later was the key to my issue.
Firstly, my main.cpp file:
Code:
#include <stdlib.h>
#include <SDL/SDL.h>
int main(int argc, char* argv[]) {
if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
}Note the order of includes, initially I had some trouble because I didn't have stdlib included, and then later because it came after the SDL include.
Then my makefile:
Code:
CC = g++
DEBUG = -g
OPTIMIZE = -O
LIBS = -lSDL
CFLAGS = -Wall $(DEBUG) $(OPTIMIZE)
CPPFLAGS = -Wall $(DEBUG) $(OPTIMIZE)
MY_FILES = main.o
umbra: $(MY_FILES)
$(CC) $(CFLAGS) $(MY_FILES) `sdl-config --cflags --libs` -o ../test_sdlapp
clean:
rm -f *.o
rm -f ../test_sdlappThis will get you started working with SDL. After this you can browse the fine documentation on the sdl website to provide for setting up a surface, and entering an event loop.
This code won't add nifty items to your menu bar or any of the other things you expect from a regular SDL template Project Builder app, but it will work. You have to force quit this example to get it to stop Cmd+Option+Escape
I really hope someone else finds this useful. If so, please let me know ( I need good news )
-Thomas
Well, besides that you made an excellent post (warms my newly-appointed moderator heart), with respect to topic, acknowledgement of crossposting and to-the-point questions, I really think that info belongs in the FAQ. (Which is sadly down, but Carlos, don't purge this post until it's in the FAQ, right?)
The FAQ itself is still up: http://macgamewiki.crissman.net/ -- only the links on iDev itself are broken
(Incidentally, the undefined _main is because you need SDL_main.m compiled in as well. I realize you've solved this in a different way, but I thought you might be able to use that piece of knowledge).
(Incidentally, the undefined _main is because you need SDL_main.m compiled in as well. I realize you've solved this in a different way, but I thought you might be able to use that piece of knowledge).
That URL hasn't been working (at least for me) in a couple of months...
Working fine for me...
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Sample Code Apple removed? | SaxMan | 12 | 5,706 |
Jan 17, 2009 05:26 PM Last Post: AnotherJake |
|
| FBO sample code posted | arekkusu | 5 | 3,977 |
Sep 20, 2006 09:23 PM Last Post: Frank C. |
|
| TextureRange sample | Red Marble Game | 1 | 2,612 |
Dec 9, 2004 12:04 PM Last Post: arekkusu |
|
| s3tc tools / sample code? | arekkusu | 2 | 3,269 |
Apr 13, 2003 06:40 PM Last Post: ibullard |
|
| Using GL Extensions in latest Project Builder | Bossa Nova | 1 | 2,491 |
Feb 26, 2003 05:25 PM Last Post: OneSadCookie |
|

