2
#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"

Is Compiled with this command:

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

But I get this error:

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

From googling, If I try to add : #include "SDLMain.h" it has major Aneurisms.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
David van Dugteren
  • 3,879
  • 9
  • 33
  • 48
  • This question is solved in XCode with the following question/answer: http://stackoverflow.com/questions/7071971/simply-including-sdl-header-causes-linker-error – bentford Oct 18 '12 at 20:53

1 Answers1

5

Change your compilation line to:

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

On my mbp, sdl-config --cflags --libs outputs:

-I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE
-L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Don't include "SDLMain.h" if you don't need it. And my guess is you don't need it. – karlphillip Oct 26 '10 at 00:51
  • @David replace the sdl-config at the end of the command by the other 2 lines I pasted in the end of my answer. Of course, you must check if your stuff is also on the same path as mine. If not, *find* them. – karlphillip Oct 26 '10 at 01:14
  • 1
    Thanks, Karl, I wasn't thinking, and had to ./configure, make, install SDL Source first. – David van Dugteren Oct 26 '10 at 01:47