在MAC上编译SDL

时间:2010-10-26 00:38:42

标签: c macos gcc ffmpeg sdl

#include "ffmpeg/libavcodec/avcodec.h"

#include "ffmpeg/libavformat/avformat.h"

#include "ffmpeg/libswscale/swscale.h"
#include "ffmpeg/libswscale/rgb2rgb.h"
#include "ffmpeg/libswscale/swscale_internal.h"

#include <stdio.h>

#ifdef __MINGW32__
#undef main /* Prevents SDL from overriding main() */
#endif

#include "SDL.framework/Headers/SDL.h"
#include "SDL.framework/Headers/SDL_thread.h"

使用此命令编译:

gcc -o t1 tutorial01.c -lswscale -lavutil -lavformat -lavcodec -lz -lavutil -lm -framework SDL

但是我收到了这个错误:

Undefined symbols:
  "_main", referenced from:
      start in crt1.10.6.o
     (maybe you meant: _SDL_main)
ld: symbol(s) not found
collect2: ld returned 1 exit status

从谷歌搜索,如果我尝试添加:#include“SDLMain.h”它有主要的动脉瘤。

1 个答案:

答案 0 :(得分:5)

将编译行更改为:

gcc -o t1 tutorial01.c -lswscale -lavutil -lavformat -lavcodec -lz -lavutil -lm `sdl-config --cflags --libs`

在我的mbp上,sdl-config --cflags --libs输出:

-I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE
-L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa