iDevGames Forums
(SDL) command line commpiling questions - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: (SDL) command line commpiling questions (/thread-2640.html)



(SDL) command line commpiling questions - caffeinated - May 10, 2008 09:10 AM

alright so I've gotten it to work on linux (arch) and Windows already so now i need to compile on Mac,

gcc pong.c -o pong -lSDL_ttf -framework Cocoa


doesn't work properly.

Here are my headers.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <SDL/SDL.h>
#include <SDL_ttf/SDL_ttf.h>

Thanks in advance.

edit: here are my errors
/Library/Frameworks/SDL_ttf.framework/Headers/SDL_ttf.h:33:17: error: SDL.h: No such file or directory
/Library/Frameworks/SDL_ttf.framework/Headers/SDL_ttf.h:34:24: error: begin_code.h: No such file or directory
/Library/Frameworks/SDL_ttf.framework/Headers/SDL_ttf.h:232:24: error: close_code.h: No such file or directory


I've already installed SDL.framework and SDL_ttf.framework so I'm not sure what the problem is.


(SDL) command line commpiling questions - OneSadCookie - May 10, 2008 10:13 AM

try something like gcc pong.c -o pong -I/Library/Frameworks/SDL.framework/Headers -framework SDL -framework SDL_ttf -framework Cocoa

Of course, you'll need to make an app bundle at some point, but hopefully that should get you started...


(SDL) command line commpiling questions - Skorche - May 10, 2008 11:31 AM

You are also going to need to link to libSDLMain on OS X. It's a small bit of Obj-C code that interfaces with Cocoa.


(SDL) command line commpiling questions - caffeinated - May 10, 2008 03:08 PM

/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status


is my new error and I suppose that I would normally fix this with '-lSDLmain' but thats not really helping, ugh... would it just be easier to make a xcode project? I'd still end up doing mostof the work in vim and what not.


(SDL) command line commpiling questions - OneSadCookie - May 10, 2008 04:01 PM

You need to locate SDLMain.m and SDLMain.h and add SDLMain.m to your compile, or to locate libSDLMain.a and add -L/path/to/it -lSDLMain to your compile. From memory, the former is more likely Wink


(SDL) command line commpiling questions - Duane - May 10, 2008 06:15 PM

There's actually a better SDLMain.m that makes the app *slightly* more macified; i.e. with full menus and stuff.

Yea, here it is. Aaron Sullivan is hosting it, so if it's down (I hesitate to click), he's on the forums.


(SDL) command line commpiling questions - caffeinated - May 10, 2008 07:56 PM

GRR, still cant get it

heres what I've tried

gcc pong.c -o pong -I/Library/Frameworks/SDL.framework/Headers -framework SDL -framework SDL_ttf -framework Cocoa -LSDLMain -lSDLMain

and the error provided..

/usr/bin/ld: can't locate file for: -lSDLMain
collect2: ld returned 1 exit status


This is using the one Nayr provided ( further provided by Aaron Smile )

I moved the folder to the same as pong.c's and renamed it SDLMain


I guess I get this because -lSDLMain is suppose to link to a library, Im not sure how i'm suppose to do it exactly.


ive also tried copying SDLMain.m to pong.c's directory and removing -LSDLMain
and I've also tried it with and without .m attached


(SDL) command line commpiling questions - OneSadCookie - May 10, 2008 07:59 PM

put SDLMain.h and SDLMain.m in the same directory as pong.c, then do

gcc pong.c SDLMain.m -o pong -I/Library/Frameworks/SDL.framework/Headers -framework SDL -framework SDL_ttf -framework Cocoa


(SDL) command line commpiling questions - caffeinated - May 10, 2008 08:33 PM

AH HA.

I got it now.. I had to hunt down SDLMain.h, lol didn't have one.

It all works now, finally.

Thanks for all your help now I can compile it on my main system... (I know weird right?)




I won't be posting it online until I read a bit more, then fix a few more things then read some more then add some more functionality etc etc etc...
( 4 player online/realtime pong anyone? thats my goal at least.. )