Dose anyone know how to set up SDL (simple direct media layer) on OSX Lion so I can compile my code with g++ ? I have read the "readme" that comes with the package and I have placed the frameworks folder in the relevant directory, however, this does not seem to be enough. Can anyone help me ? (I do not want to use Xcode)
Asked
Active
Viewed 2,614 times
3
-
Which errors are you getting? You probably need to tell g++ to link with the SDL binaries – dario_ramos Feb 29 '12 at 12:24
-
This is the exact error i get: library not found for -lSDLmain collect2: ld returned 1 exit status Joes-MacBook-Pro:SDL Joe$ g++ main.cpp -framework SDL Undefined symbols for architecture x86_64: "_main", referenced from: start in crt1.10.6.o (maybe you meant: SDL_main()) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status – lilroo Feb 29 '12 at 12:58
-
It seems like before calling g++ with the `-framework` option, you need to call it with the `-ln` option. Take a look at [this](http://www-h.eng.cam.ac.uk/help/tpl/languages/C++/InstallingC++graphicslibs.html), in the MacOs subsection. – dario_ramos Feb 29 '12 at 13:50
-
Just created a symbolic link to the SDL framework directory and i'm still getting the same error – lilroo Feb 29 '12 at 13:56
-
1[This guy](http://stackoverflow.com/questions/7071971/simply-including-sdl-header-causes-linker-error) got the same error and solved it. – dario_ramos Feb 29 '12 at 14:07
-
When I get that main error it is usually from not have the main.m and main.h files that are included with SDL in my project. Try adding those. Here is a [tutorial](http://samwalkercs.blogspot.com/2011/12/setting-up-sdl-to-work-with-xcode-42-on.html) that works for me. – Sam Walker Feb 29 '12 at 18:57
1 Answers
6
If you're not using XCode, and are compiling SDL projects using gcc
, you can run:
gcc -o test SDLTest.c `sdl-config --cflags --libs`
g++ -o test SDLText.c `sdl-config --cflags --libs`
This works happily for me on my mac - sdl-config --version
returns 1.2.14
, and I can run test
:)

simont
- 68,704
- 18
- 117
- 136