C++ and SDL compiling via command line?
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:
(My test program contains "#include "SDL.h")
Any ideas what I'm doing wrong?
I've tried the following command, but it gives me errors about not finding SDL:
Code:
g++ -o main main.cpp -libSDLmain
(My test program contains "#include "SDL.h")
Any ideas what I'm doing wrong?
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.
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.
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
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Glyph Designer Command Line app released | MikeD | 1 | 4,981 |
Jan 2, 2013 12:56 AM Last Post: NikG |
|
Port of Cortex Command? | Frejesal | 7 | 11,560 |
Dec 9, 2008 09:05 PM Last Post: montdidier |
|
Mac os x Port of Cortex Command, it is time | Mr_Sanders | 4 | 8,855 |
Dec 9, 2008 09:03 PM Last Post: montdidier |
|
(SDL) command line commpiling questions | caffeinated | 8 | 10,192 |
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 | 4,266 |
Nov 17, 2007 12:21 PM Last Post: OneSadCookie |