(SDL) command line commpiling questions

Apprentice
Posts: 6
Joined: 2008.05
Post: #1
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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...
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
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.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2008.05
Post: #4
/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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
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
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #6
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.

It's not magic, it's Ruby.
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2008.05
Post: #7
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
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
Quote this message in a reply
Apprentice
Posts: 6
Joined: 2008.05
Post: #9
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.. )
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Glyph Designer Command Line app released MikeD 1 3,078 Jan 2, 2013 12:56 AM
Last Post: NikG
  C++ and SDL compiling via command line? sugar 2 6,072 Mar 26, 2009 10:07 AM
Last Post: Volte
  Port of Cortex Command? Frejesal 7 8,759 Dec 9, 2008 09:05 PM
Last Post: montdidier
  Mac os x Port of Cortex Command, it is time Mr_Sanders 4 6,769 Dec 9, 2008 09:03 PM
Last Post: montdidier
  How do you compile using the 10.3.9 SDK at the command line? Malarkey 2 3,008 Nov 17, 2007 12:21 PM
Last Post: OneSadCookie