wiki:

CompilationGuide

/

CrossCompilingForWindows


Version 5 (modified by Timothy_Gu, 5 years ago) (diff)

Add automated build system section

Intro

Basically, cross compiling FFmpeg for windows means that you use a special version of the gcc compiler (and related tools) that output a working windows executable when they're done. You can copy it to your windows box and then use it (or use wine to run it under linux, but that kind of defeats the point).

This is sometimes easier than using a "native" compilation in windows because some dependencies' configure scripts accept a cross compiler more readily than a native windows mingw gcc, etc. It also may be "faster" than using mingw's gcc in windows, for whatever reason gcc seems faster in linux.

Automated cross compiling environment

Some building environments that aim to automatically build the cross compilers and dependencies of FFmpeg are available. These projects include MXE and Win-builds. Note that the former is more feature-complete as of Dec 2013 (it has more dependencies for FFmpeg, and it has a ffmpeg package; and it supports OS X as a host machine), while the latter is the official package manager for mingw-w64.

Cross Compiler

Zeranoe has a script for compiling your own windows cross compiler, then you can use it to compile ffmpeg and its libs. NB that it can be a little tricky, you could try using this script which attempts to automated building the cross compiler and gcc.

Another option is that some linux distros have packages like mingw-w64-dev or gcc-mingw-w64-i686 which might also get a working local cross compiler system. Basically, they'll add x86_64-w64-mingw32-gcc to a directory or to the PATH somehow. And you're ready to go.

Compile dependencies

Next cross compile any added dependencies you may want, for instead libx264.

The script "cross_compile_ffmpeg.sh" in this repository lists many dependencies.

Compile FFmpeg

Now basically configure and compile FFmpeg like

$ ./configure -enable-memalign-hack  --arch=x86   --target-os=mingw32    --cross-prefix=i686-w64-mingw32-  --pkg-config=pkg-config
$ make

and other options if you want them, like --enable-libx264, etc.

This should eventually create the file ffmpeg_g.exe (ffmpeg.exe with debug symbols) and ffmpeg.exe (ffmpeg.exe "stripped" of its debug symbols). If you cross compile SDL before hand, it will also include ffplay.exe

Resources

This repository has a script that compiles the cross compiler locally

You can ask questions on the Zeranoe Forum.