我一直试图让一个超级简单的SDL程序工作.我正在使用Mac OS X Lion.我有SDL在Snow Leopard工作,但它似乎不想在狮子身上工作.到目前为止我有这个:
#include <iostream> #include "SDL/SDL.h" using namespace std; /* #ifdef main # undef main #endif */ int main( int argc,char* args[] ) { SDL_Surface* hello = NULL; SDL_Surface* screen = NULL; SDL_Init( SDL_INIT_EVERYTHING ); screen = SDL_SetVideoMode( 640,480,32,SDL_SWSURFACE ); hello = SDL_LoadBMP( "hello.bmp" ); SDL_BlitSurface( hello,NULL,screen,NULL ); SDL_Flip( screen ); SDL_Delay( 2000 ); SDL_FreeSurface( hello ); SDL_Quit(); return 0; }
当我尝试编译此代码时(在Xcode 4.1中),它给了我这个错误:
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 clang: error: linker command Failed with exit code 1 (use -v to see invocation)
如果我取消注释当前评论的#ifdef内容,程序将编译,但随后会在SDL_SetVideoMode行上接收SIGABRT.我刚才在另一个程序中看到了这些注释的东西,我不确定我是否应该拥有它.
我怎么能让这个工作?