View Full Version : cmd line okay, SDL not
LWStrike
2006.03.24, 07:46 PM
I recently got my mac and i started to play with xcode and manage to port one of my command line programs to mac.
Now i like to port a small editor i wrote in SDL and i tried installing SDL but i just cant get it working (PS I got it working on both windows and Fedora Core 4 linux). What i did was open one of the template SDL apps (it was in xcode after i installed the SDL package). When i compile i get linking errors (_SDL_PushEvent, _SDL_GetError, _SDL_Init, _SDL_PollEvent, _SDL_Quit, _SDL_SetVideoMode) does anyone know an easy solution for this?
As a side note when i made a 'empty project' i couldnt get my cmd line programming compiling. When i used the hello world template i had it running in no time. Why is that? where can i learn how to set these configuration? i rather not poke blindly at xcode which looks very big.
LWStrike
2006.03.25, 11:45 PM
I tried making an empty project, setting the target to carbon app and setting the path to include the SDL header directory. It does compile but it does not 'run'. Technically it does run but it does nothing at all and i can only stop it from running by hitting terminate. If i remove the SDL.h include it runs fine (all it does is a printf).
I know SDL changes my main into SDL_main in the header, but why isnt it running my main? i never had this problem with windows (using msvc, cmd line mingw and using code::blocks with mingw). Never had problems with it using gcc on linux (cmd line and kdevelop). Whats with this >_<
sealfin
2006.03.26, 04:55 AM
LWStrike, as you started with an empty project, are you including (not #include'ing) SDLMain.h and SDLMain.m in your project?
LWStrike
2006.03.26, 11:48 AM
Yes for the first, No for the 2nd. The first was a template in the carbon section which get the linking error (_SDL_PushEvent, _SDL_GetError etc). No with the 2nd (just printf).
I just added a quick SDL_Init(0); and SDL_Quit() to the 2nd app and it compiled without linking errors. Like before, it does not 'run'. If i comment out the 2 SDL calls and the header it does run and terminates.
LWStrike
2006.03.26, 04:02 PM
I forgot to mention i am running tiger on an intel mini.
BTW i tried DL sdl source and using ./config (no luck) then ./configure (which work) and then make which got some errors. So is SDL not supported on intel machines? or is my machine not set up properly?
sealfin
2006.03.26, 04:55 PM
SDL is supported on Intel Macs, although not having an Intel Mac I haven't personally tried it - however, I'm not sure if the SDL library currently available from the official SDL site is a Universal Binary; if not, if that is where you've retrieved the library from, that may be the cause of your troubles...
LWStrike
2006.03.28, 12:43 AM
I tried the CVS version and i was able to make and make install SDL, but i still get the problems >_<.
Maybe somone can send me a prebuilt app and project file i can test with
unknown
2006.03.28, 02:58 AM
SDLOpenGL.c
// gcc SDLOpenGL.c `sdl-config --libs` -lSDLmain -framework Cocoa -framework OpenGL -o SDLOpenGL
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_main.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#define TEXTURED_QUAD \
glBegin(GL_QUADS); {\
glTexCoord2i(0, 0); glVertex2i(0, 0);\
glTexCoord2i(1, 0); glVertex2i(1, 0);\
glTexCoord2i(1, 1); glVertex2i(1, 1);\
glTexCoord2i(0, 1); glVertex2i(0, 1);\
} glEnd()
void initialize();
void draw();
int main(int argc, char **argv) {
SDL_Surface *screen;
SDL_Event event;
int done = 0;
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screen = SDL_SetVideoMode(640, 480, 32, SDL_OPENGLBLIT);
initialize();
while(!done) {
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
done = 1;
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
break;
}
}
draw();
SDL_GL_SwapBuffers();
}
return 0;
}
void initialize()
{
glClearColor(1, 0, 0, 1);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, 640, 480, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void draw()
{
glClear(GL_COLOR_BUFFER_BIT);
}
LWStrike
2006.03.28, 01:24 PM
I meant an actual project that is allready configured (so i cant make a mistake).
I didnt think i had gcc installed. I enter that line in the terminal and got this. I guess i do have a bad setup
-bash: sdl-config: command not found
/usr/bin/ld: Undefined symbols:
_SDL_GL_SetAttribute
_SDL_GL_SwapBuffers
_SDL_Init
_SDL_PollEvent
_SDL_SetVideoMode
_SDL_PushEvent
In case i need to do this for other projects, how do i enter the libs (-i)? what section is it in xcode? i think i know how to add framework (i have an openGL app running with glut) and i allready found user search path and preprocessed macros in xcode.
So my build is messed up, can send me a universal binary that require SDL so i can check if the runtime is correct? rapidshare.de is a good site to put files onto. No reg.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.