I was going to migrate my game from glut开发者_如何学JAVA to sdl.
It's working perfectly in glut but I wanted to use some sdl features.
So I go into my project properties, under the targets header I click the program that will be compiled, build phases, link binary with libraries, add SDL.framework
The exact same as I have done for OpenGL.framework and GLUT.framework
However when I add: #include <SDL/SDL.h>
it comes up with a linker error when I try to build:
Undefined symbols for architecture x86_64:
"_main", referenced from:
__start in crt1.o
(maybe you meant: _SDL_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Googling simply leads to a fair few results, but no real explanations.
SDL uses a macro to rename your main(..)
and should supply its own, usually implemented in SDLmain.m
. It should be supplied together with the SDL.framework.
When you download the framework from here http://www.libsdl.org/download-1.2.php Read the ReadMeDevLite.txt
in the devel-lite
folder.
Another description http://www.meandmark.com/sdlopenglpart2.html
I have found that when I get the error :
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: _SDL_main)
I have forgotten to go to Project -> Build Phases -> Compile Sources and add SDLMain.m to the list. This solved the problem for me right away.
精彩评论