How to cross-compile ffmpeg for Windows

Notes. Assumes:

  • SDL headers in ../../withplayer_win/SDL/include
  • SDL.dll in ../../withplayer_win/SDL/src/.libs/SDL.dll
  • A cross compiler set /home/jdmol/withplayer_win/xcomp/bin/mingw32-*. Create one with the attached install_xcc script, which creates an xcomp dir and builds a cross-compiler in it. Have patience and 1GB of diskspace.
  • The attached uname should be in the beginning of the path (code below assumes {{../../win32}}} dir)
mkdir svn

cd svn

svn checkout svn:// ffmpeg

cd ffmpeg

PATH=../../win32:$PATH CFLAGS=-I../../withplayer_win/SDL/include LDFLAGS=../../withplayer_win/SDL/src/.libs/SDL.dll  ./configure  --enable-mingw32 --cpu=i686 --arch=i386 --enable-memalign-hack --cross-prefix=/home/jdmol/withplayer_win/xcomp/bin/mingw32- --cc=gcc


make ffplay.exe

Now, copy ffplay.exe and ../../withplayer_win/SDL/src/.libs/SDL.dll to your Windows machine.

Update for new ffmpeg versions

(Tested with ffmpeg SVN revision 8885)

Follow the procedure above, with the following differences:

  • uname is not needed anymore
  • the SDL headers are in ../SDL/include
  • the SDL.dll is in ../SDL
  • Use the following configuration line instead
    ./configure --extra-cflags="-I../SDL/include -I/usr/win32/include" --extra-ldflags="../SDL/SDL.dll 
    -L/usr/win32/lib" --cross-compile --target-os=mingw32 --cpu=i686 --arch=i386 --enable-memalign-hack 
    --cross-prefix=/home/ivaylo/tribler/xcomp/bin/mingw32- --cc=gcc --enable-libfaad --enable-libfaac --enable-gpl --enable-x264
  • If they did not fix this, you might need to add the headers below in libavcodecvc1_parser.c to get it compiling:
    #include "dsputil.h"
    +#include "bitstream.h"  
    +#include "mpegvideo.h"  
    #include "parser.h"
    #include "vc1.h"