C++ and SDL compiling via command line?

Posts: 1
Joined: 2009.03
Post: #1
I much prefer to compile via command line. I'm trying to get SDL set up and to compile correctly. I've added SDL.framework to /Library/Frameworks/

I've tried the following command, but it gives me errors about not finding SDL:
g++ -o main main.cpp -libSDLmain

(My test program contains "#include "SDL.h")

Any ideas what I'm doing wrong?
Quote this message in a reply
Posts: 111
Joined: 2002.06
Post: #2
Because you're using the SDL framework, you must link against the SDL framework, not libSDLmain. Use the -framework flag to link frameworks.

You're going to have to add SDLmain.m to the list of files you're compiling. You may also have to link against the Cocoa framework. If you're going to compile from the command line, you may want to create a makefile so you don't have to enter a bunch of -framework flags every time you want to compile your code.

Xcode uses gcc to compile, and the Mac version of the SDL development libraries comes with Xcode project templates. By creating an Xcode project and building it, you can see how Xcode compiles SDL programs, which will help you know what you have to do to compile from the command line. Open Xcode's build results window by choosing Build > Build Results. There will be four small buttons in the lower left corner of the build results window. Click the third button to open the build transcript, which shows you the steps Xcode takes when building a project.

Mark Szymczyk
Quote this message in a reply
Posts: 89
Joined: 2005.06
Post: #3
Also, IIRC, -l stands for library, so you're technically telling it to look for the 'ibSDLMain' library. Try -lSDLMain next time, but szymczyk is right, you just need SDLMain.h/m in your project and then just link to -lSDL

Well since everyone else is doing it:
Twilight Coders
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 2,529 Jan 2, 2013 12:56 AM
Last Post: NikG
  Port of Cortex Command? Frejesal 7 8,470 Dec 9, 2008 09:05 PM
Last Post: montdidier
  Mac os x Port of Cortex Command, it is time Mr_Sanders 4 6,554 Dec 9, 2008 09:03 PM
Last Post: montdidier
  (SDL) command line commpiling questions caffeinated 8 6,431 May 10, 2008 08:33 PM
Last Post: caffeinated
  How do you compile using the 10.3.9 SDK at the command line? Malarkey 2 2,889 Nov 17, 2007 12:21 PM
Last Post: OneSadCookie