Building ffmpeg for Windows with MSYS and MinGW

It took me the better part of a day to convince the snotty ffmpeg source code that it’s quite alright to be compiled under Windows even if it was written originally for Linux.

For those of you who don’t know what ffmpeg is and for some reason are still reading this, ffmpeg is a library of codecs for every conceivable audio and video format out there. The best part about it is that it doesn’t depend on the codecs you have installed on your system (which is a particular nightmare on Windows-based machines).

As for me, I was trying to extract the first image of video files to use as thumbnails in a video upload tool I’m working on.

We’ll start with downloading some tools of the trade and the source for ffmpeg.

  1. Download MinGW from here.
  2. Download MSYS from here.
  3. Download updated bash for MSYS from here.
  4. Get the latest snapshot of ffmpeg from here (here’s a direct link).

Let’s install the tools.

  1. Install MinGW (choose “MinGW base tools” and “MinGW make”) into c:\mingw
  2. Install MSYS into c:\msys\1.0
  3. After MSYS installation it will run a postinstall script. It will ask you some questions which you should answer as following:
    Do you wish to continue with the post install? [yn ] -> y
    Do you have MinGW installed? [yn ] -> y
    Where is your MinGW installation? -> C:/mingw
  4. Copy bash-2.05b-MSYS.tar.bz2 to c:\msys\1.0 and extract it (bash.exe should go into C:\MSYS\1.0\bin).
    We need to do this because ffmpeg’s configure script doesn’t work with bash 2.0.4 that comes with MSYS.
  5. Extract the ffmpeg sources. I’ll assume you’ve extracted them to c:\work\ffmpeg .

Now it’s time to build the library.

  1. Create a file called myconfig in c:\work\ffmpeg and copy the following into it:
    ./configure –extra-cflags="-mno-cygwin -mms-bitfields"
    –extra-ldflags="-Wl,–add-stdcall-alias" –enable-memalign-hack
    –target-os=mingw32 –enable-shared –disable-static
  2. Run c:\msys\1.0\msys.bat. Run the following commands in the shell that starts:
    $ cd /c/work/ffmpeg
    $ ./myconfig
    $ make
  3. In order to run ffmpeg.exe, collect the binary files and put them together in one folder:

61 Comments on “Building ffmpeg for Windows with MSYS and MinGW”

By Sarreq Teryx. April 1st, 2007 at 07:46

I’m following that perfectly (except for fixing the switch prefixes) and I get:

Unknown option “–enable-mingw32″.
See ./configure –help for available options.

and when I remove –enable-mingw32 I get:

gcc is unable to create an executable file.
If gcc is a cross-compiler, use the –cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.
If you think configure made a mistake, make sure you are using the latest
version from SVN. If the latest version fails, report the problem to the mailing list or IRC #ffmpeg on
Include the log file “config.err” produced by configure as this will help
solving the problem.

what’s going on here

By Eli Golovinsky. April 4th, 2007 at 09:00

They seem to have removed the –enable-mingw32 option and offer to use –target-os=mingw32 instead. I’ve updated the post.

Thanks for letting me know.

By Duncan Cross. October 15th, 2007 at 01:50

The link for updated bash is source, not binary.

By Duncan Cross. October 15th, 2007 at 02:27

Sorry about that crabby last comment, I’m actually very grateful that there’s at least one place on the web that bothers to go into this stuff properly – thank you.

It looks like ./configure has gone through more changes since you wrote this – it no longer seems to like a lot of the options specified here, and also when I try to get around that I get the error “line 181: pr: command not found” a few dozen times.

By gooli. October 15th, 2007 at 08:31

If you do figure out how to do this with the current version of ./configure, please post it here so I could update the post.

By 45tripp. November 15th, 2007 at 12:40

>“line 181: pr: command not found”

it’s in the faq,
pr is not part of the main msys,
you need to get it from coreutils

By Eder. November 22nd, 2007 at 14:19

So, how do we build ffmpeg for windows, but using a linux host, with cross-compiling ?

By gooli. November 22nd, 2007 at 14:22

That’s a bit out of my league I’m afraid.

By Franck. November 22nd, 2007 at 14:30

hello when i try to do ./myconfig it give me some error like that and i really dont know of to fixe the problem:
$ ./myconfig
Broken shell detected. Trying alternatives.
Trying shell bash
Unknown option “–extra-cflags=-mno-cygwin”.
See ./configure –help for available options.
./myconfig: –extra-ldflags=-Wl,–add-stdcall-alias: command not found
./myconfig: –target-os=mingw32: command not found

I have installed all stuff with upgrade 2.05 for msys. the bash.exe is in the bin folder and others extracted folders are added to 1.0 folder.

By franck. November 22nd, 2007 at 16:40

Last Question is the last ffmpeg from svn have the ‘-vhook’ option includ if we build like you do ?

By Mark. December 24th, 2007 at 14:48

Great guide, thanks! To comment on the previous posts:
Link to the binary bash:

This config worked for me (removed most of the arguments):
./configure –enable-memalign-hack

By libesh. January 23rd, 2008 at 07:25


I followed these instructions to install ffmpeg.
I installed MinGW and MSYS according to the instructions. Also included bash.exe.
./myconfig does not work.
Shows the error message…..
Unknown option “–extra-cflags=-mno-cygwin”.
See ./configure –help for available options.
./myconfig.txt: line 3: –extra-ldflags=-Wl,–add-stdcall-alias: command not found
./myconfig.txt: line 4: –target-os=mingw32: command not found

I also included –enable-vhook
But error message will come.

By wuwei. January 29th, 2008 at 09:52

[./configure ....] is one line.
not copy! Otherwise be splited 3 lines.

By harpal. February 4th, 2008 at 13:54

Hello friends I have same error. I download batch File.

$ ./myconfig
Broken shell detected. Trying alternatives.
Trying shell bash
Unknown option “–extra-cflags=-mno-cygwin”.
See ./configure –help for available options.
./myconfig: –extra-ldflags=-Wl,–add-stdcall-alias: command not found
./myconfig: –target-os=mingw32: command not found

Can u please slove this Issue? I am very near to do it but now I am totally stuck in the middle.
please any help?

By naveent. February 4th, 2008 at 15:43

how can i use these tools to compile ffmpeg for
Red Hat Enterprise Linux 5 PAE 2.6.18-8.el5PAE
is our shared server.

By naveent. February 4th, 2008 at 15:45

how to include the lame libraries within an ffmpeg binary for a linux version using MINGW.

By harpal. February 5th, 2008 at 13:35

Hello friend,
I did it on windows xp and it is great.
I will suggest you to read the things very carefully.

I am so happy now.

By Bosco. February 8th, 2008 at 21:32

Substitute all the “-” typing the “-” after copy/paste all the instructions on the myconfig file… That’s the problem.

By Bosco. February 8th, 2008 at 21:35

Ando also use 2 “-”, like this:

./configure –extra-cflags=”-mno-cygwin -mms-bitfields” –extra-ldflags=”-Wl,-add-stdcall-alias” –enable-memalign-hack –target-os=mingw32 –enable-shared –disable-static

By Bosco. February 8th, 2008 at 21:38

The problem is that when we post here, 2 — turn into 1 -. For instance, I’ve written –(two )extra-cflags=…. and maybe you’ll see just – (one)

By Han. March 1st, 2008 at 05:32

I did all as the instruction,but i got some troubles, error is:
$ ./myconfig
error, no memalign() but sse enabled, either disable it or use –enable-memalign-hack

(I really don’t know which positions is used with 2 –)

By Anthony. March 7th, 2008 at 23:51

I am also getting the memalign error:
“Error, no memalign() but SSE enabled, disable it or use –enable-memalign-hack.”

I have an old Athlon Thunderbird CPU that doesn’t have SSE.

Anyone know a solution?

By Debelyoo. April 1st, 2008 at 11:38

Hi all,
Thanks for your posts. I could install MINGW + MSYS with the new bash and configure FFMPEG using the mycompile script. Great.
However, the make fails. It gives a lot of “undefined reference”. A few examples below:
c:/ffmpeg/libavutil/log.c:45: undefined reference to ‘__getreent’
c:/ffmpeg/libavutil/mem.c:45: undefined reference to ‘memalign’

Do you know what could be the problem ? Do I miss a library ?

By Richard. April 22nd, 2008 at 13:45

I followed all your steps to complie the FFMpeg, but after I run the ./myconfig in the mingw32, there’s errers : ”
gcc is unable to create an executeable file.
C compiler test failed.

Could you please help me ? what I should do to fix this problem ? Thank you very much.

If possible, could we make friends ?
msn :
skype : iamwheat
yahoo : wheatinthesky


By ZeOn. May 1st, 2008 at 09:57

The solution is as followed:
download the coreutils and in the myconfig just put:
./configure –extra-cflags=”-mno-cygwin -mms-bitfields” –extra-ldflags=”-Wl,-add-stdcall-alias” –enable-memalign-hack –target-os=mingw32 –enable-shared –disable-static

=>- becomes — only when it’s between “” it’s a single -

By Keka. May 6th, 2008 at 23:38

Hi, I am green at this and need help. I have followed the guide up to the point of executing the Make command.I am getting the message ***No rule to make target ‘libavdevice/avdevide.dll’needed by ‘all’ .Stop

How do I resolve this?
regards Keka

By Jer. May 11th, 2008 at 11:16

Extract coreutils downloaded from
into c:/msys/1.0 so that it overwrites items in subdirs (bin, lib, etc.) I opened the .tar.bz2 with 7zip, went down 2 levels, highlighted the 4 or 5 folders, copied them and pasted in c:\mingw.

decend to c:\mingw\libexec\mingw32\3.45\
copy the 6 .exe’s there.
ascend to c:\mingw\bin

Update make:
download from
extract bin and share folder to c:\msys\1.0 (allow to overwrite)

start c:\msys\1.0\msys.bat

type out:

./configure –extra-cflags-”-mnt-cygwin -mms-bitfields” –extra-ldflags=”-Wl, -add-stdcall-alias” –enable-memalign-hack –enable-shared –disable-static –target-os=mingw32_nt-6.0

double – before ‘extra’ ‘enable’ ‘disable’ and ‘target’. Wl is a capital W and a small L.

**target OS I put mingw32_nt-6.0. My windows boot is Vista. Not sure if it is required to be that way but it worked.

(or you can put in myconfig and run c/work/ffmpeg/myconfig. I’m just used to typing out ./configure lines because I end up compiling a lot of stuff on linux and the myconfig method seems like the long way around to me.)

Run make, et voila! Enjoy.

By Jer. May 11th, 2008 at 11:21


You will also need ffmpeg/libavdevice/avdevice-52.dll

(and avformat is avformat-52.dll with latest ffmpeg)

Happy ffmpeging

By Marco L.. July 25th, 2008 at 01:19

Hi, nice guide! I followed all your steps, and I have made all the dll (avcodec-51.dll, avformar-52.dll, avutil-49.dll and avdevice-52.dll) but I have another problem!
When I want to encode a frame with Visual Studio and I use the avcodec_encode_video, at the second call of this function there is an exception:

Eccezione first-chance occurred in avcodec-51.dll in EncodeMpeg4.exe: 0xC00000FD: Stack overflow.
Eccezione non gestita occurred in avcodec-51.dll in EncodeMpeg4.exe: 0xC00000FD: Stack overflow.

Someone tell me there is a problem with the stack alignment.
This kinf of error appear only when I encode a frame (AVPicture in PIX_FMT_YUV420P) not appear when I decode a stream of byte with the avcodec_decode_video.
Obviously I have made any kind of initialization like avcodec_init, av_register_all, avcodec_register_all, …

Any idea?
Thanx in advance :)

By rgk. August 15th, 2008 at 22:31

The following myconfig worked for me

./configure –extra-cflags=”-mno-cygwin -mms-bitfields” –extra-ldflags=”-Wl -add-stdcall-alias” –enable-memalign-hack –target-os=mingw32 –enable-shared –disable-static

How ever I had to make some changes to msys to get all of this to work properly

1)Install msysDTS (msysDTK-1.0.1.exe)

2)Install MSYS Core 1.0.11. (msysCORE-1.0.11-2007.01.19-1.tar.bz2)

3)Install msys coreutils (coreutils-5.97-MSYS-1.0.11-snapshot.tar.bz2)

4)Update bash to v.31 (bash_3.1_MSYS-1.0.11)

5)Update make to version 3.81 (make-3.81-MSYS-1.0.11-2)

got all of the above from

Then compile went cleanly..
Hope this helps some of the folks..

By rgk. August 15th, 2008 at 22:35

One other thing.. as Jer noted above…

ALL configure options are preceded with a DOUBLE DASH.

…this discussion board strips off the double dash i just noticed, so when you cutr and paste you will get errors unless you put them back

./configure —extra-cflags=”-mno-cygwin -mms-bitfields” —extra-ldflags=”-Wl -add-stdcall-alias” —enable-memalign-hack —target-os=mingw32 —enable-shared —disable-static

By Ian. October 6th, 2008 at 04:35

First off thanks hugely for all the info on this page, really helpful. Ive now managed to at least get the make to begin but i get a problem in the source with the ‘CAPTUREPARAMS’ as an undelcared identifier in the ‘libavdevice/vfwcap.c’ file.

Anyone have any idea how to fix? Also, i couldnt work out how to copy and paste so i cant show you the entire error output – any ideas how to do that too?

Thanks in advance,

By ltomak. October 17th, 2008 at 20:11

to solve “libavdevice/vfwcap.c” related erros use download and install w32api-3.12-mingw32-dev.tar.

By Bhavin. December 4th, 2008 at 13:12

HI thanks for this tutorial… I have installed the ffmpeg successfully but how to use this command to convert any videofile to flv file.
please help me.
thanks in advance.

By nirav. December 4th, 2008 at 13:15

i could not found “bash-2.05b-MSYS.tar.bz2″ which is required as u pls give download link for it. after setting all up how can i use ffmpeg.what shoud i do further. thanks for reply in advns.

By nirav. December 4th, 2008 at 13:24

i could not found “bash-2.05b-MSYS.tar.bz2? which is required as u pls give download link for it. after setting all up how can i use ffmpeg.what shoud i do further. thanks for reply in advns.

i have used this link to download it but it didnt give any result. pls help

By nirav. December 4th, 2008 at 15:20

i have down load bash-2.05b-MSYS.tar.bz2 but still i got following error on msys prompt and one thing that i made myconfig.txt file. is it ok?
pls help me
Broken shell detected. Trying alternatives.
Trying shell bash
Trying shell ksh
Trying shell /usr/xpg4/bin/sh
No compatible shell script interpreter found.
This configure script requires a POSIX-compatible shell
such as bash or ksh.
Instead, install a working POSIX-compatible shell.
Disabling this configure test will create a broken FFmpeg.
This bash version (2.04.0(1)-release) is broken on your platform.
Upgrade to a later version if available.
./myconfig.txt: –extra-ldflags=-Wl,–add-stdcall-alias: command not found
./myconfig.txt: –target-os=mingw32: command not found

By dan. December 15th, 2008 at 23:24

I am trying to build the ffmpeg project and am using the double -’s and have updated the core utils, and make, and using bash 2.5b but getting errors when i run the myconfig.

ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later.

I tried to manually set the environment variables just to see what would happen and that did not work either. (__W32API_MAJOR_VERSION & __W32API_MINOR_VERSION)

By dan. December 16th, 2008 at 01:11

i fixed the problem. I had to use mingwrt-3.15.1-mingw32.tar.gz to fix it. Also followed Jar’s steps and voila built.

BTW it took me 15 min to finish building the .mak and .h config files. and about 5 minutes after calling make for the exe and dlls to build. Do not expect this process to be fast by any means. I had at one point the ./myconfig call used 3 bash exe’s and over a gig of ram.

By nikhil. January 23rd, 2009 at 08:49

how do i test the .sw file output by the apiexample program

By Ward. February 20th, 2009 at 13:05

Hi, I still can’t make this work
I am stuck @ the part where I get this error:
ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later.

I downloaded mingwrt-3.15.1-mingw32.tar.gz, but I’m not sure where to place this dll…

Anyone could help me out with this, cause i really need FFMPEG urgently…


By Shrieky. February 27th, 2009 at 11:58

Dear Ward,

Replace the downloaded files in your MinGw installed directory.If still your problems persists download w32api-3.13-mingw32-dev.tar.tar from
Again replace the files downloaded.

This should solve your problem.


By Whit. March 11th, 2009 at 21:32

Ok, I spent a bit of time working through this today. I went the myconfig route like the original author. Inside the myconfig file:
First line:

Second line:
./configure –extra-cflags=”-mno-cygwin -mms-bitfields” –extra-ldflags=”-Wl, -add-stdcall-alias” –enable-memalign-hack –enable-shared –disable-static –target-os=mingw32
The second line needs to all be on one line (no carriage returns) and you’ll need a double dash in front of: extra, extra, enable, enable, disable and target. You’ll also need to type out the double quotes again on your system probably since this site screws them up too.

As for the w32api error that some of you are getting, you’ll need to extract to your MinGw installation directory.

Like Dan, it took my system about 20 minutes to build the .mak and .h config files.

By Boon. March 29th, 2009 at 02:12

follow professional link to install :

read step carefully you will able to compile.

By Sri Kumar. October 28th, 2009 at 13:08

i was able to find all(ffmpeg\libavcodec\avcodec-51.dll,ffmpeg\libavformat\avformat-51.dll,
ffmpeg\libavutil\avutil-49.dll) the dll’s in their respective dir except “ffmpeg\ffmpeg.exe” :(

What could have gone wrong? Can any one help on this?

By Ruby. December 27th, 2009 at 18:41

Helo, thx 4 da guide.Ive been trying to install ffmpeg since almost a week. Ive gone thru the whole tutorial n i even read al z comments b4 starting z installation.

still i hv dis problem
./configure: line 233: pr: command not found
gcc is unable to create an executable file.
If gcc is a cross-compiler, use the --enable-cross-compile option.

i hv even installed coreutils and make..cud u pls help me work dis problem out..i badly need ffmpeg 4 skul project of mine..

By selven. December 27th, 2009 at 20:45

heya ruby…

You may wish to check out whether it is looking for pr in the right place or not.. if you have installed coreutils, i suppose pr is installed, but your configure script for some weird reasons is looking for it in the wrong place.. you can either find where pr is and then do a sym link to it in most probable locations your config script will look for it..

or you may want to supply a different path to your configure script… try looking for pr first.


locate pr |less


By Reid. January 28th, 2010 at 18:07

Just f.y.i. if you’ve come here looking for up-to-date build instructions (these are sadly out of date), gcc has removed the -mno-cygwin flag, with vague references to changing to using cross-compiling in the gcc doc.

The flags I am (currently) trying to use are just:

../ffmpeg/configure –enable-memalign-hack –disable-ffserver –disable-ffplay

But my problem is that my “make” isn’t new enough, and the updated make uses the new lzma compression format, and the lzma tools are not quite finished.


By Chad. February 14th, 2010 at 23:13

Ugh. So if I want an up-to-date build of ffmpeg for Windows, am I out of luck? Must I wait indefinitely, or is anyone having luck using this method for the latest build (currently FFmpeg Revision 18639 21-04-09) in Windows?

By sven_de_ka. February 26th, 2010 at 01:10

I also had trouble with the pr-command and the make, but using these (”obsolete”) versions it worked out fine:

By baptiste. March 26th, 2010 at 18:31

I need PyFFmeg vor python 2.6 under windows, but i’m not able to compile it . I tried to compile it all the day , but i’m very bad in compilation task. Did somebody succed to compile it and could send me a installer for python2.6 or files to move in python26 directory ? thanks .

By Ruby. April 4th, 2010 at 09:22

4 all those who have had problems wiz pr command

All u have to do is to put the path to Pr in ur environment variables path.

Hope it helps :)

By Gins. May 18th, 2010 at 14:27


I made to the points mentioned till point4 bash-2.05b-MSYS.tar.bz2.How i download this file.When i click this link it shows an option to download minGW 5.16.Downloaded and installed.Nothing Happened.What should i do?When command is run without new bash msys the bash needs to be updated.Please help..waiting for your reply..

By shara. June 17th, 2010 at 06:15

I am not able to get bash-2.05b-MSYS.tar.bz2 file…
from where can download..
this link is not working for me…help pplz

By Mark. June 18th, 2010 at 16:56


It appears the link for bash is either incorrect or no longer valid. However, without the bash.exe, the workflow cannot be completed since running the suggested ./myconfig in MINGW32 will give the dreaded “No compatible shell script interpreter found” message. Could someone please fix the workflow or provide a work-a-round?

By Chad. June 25th, 2010 at 06:29

Hi Mark,

A simple solution to your problem is to download the new version of MSYS (1.0.11). That has the newer version of bash and should solve the configure problem.

I recommend looking at

for more clear instructions.

By Sridhar. July 5th, 2010 at 11:07

Hi Mark,
I dont find exe for MSYS 1.0.11. I get a zip file which contains bin. But I dont find any installer in it. Can you help me out.


By Sridhar. July 6th, 2010 at 05:23

Hi All.
I have been getting “Input format not supported -x11grab” when I use ffmpeg with the configuration. I understand that my ffmpeg is not compiled with x11grab, so I need to recompile it with x11grab. But to my disappointment, MSYS 1.0.11 is not allowing me to compile it. I am getting this weird error which says ” ./configure: No such file or directory” What am I missing. I am pretty new to MSYS, ffmpeg so please excuse me if my questions are very amateurish.

Also, let me know if there is any other good link which can help me understand better. I see that a lot of people have benefitted from this post, so thanks to gooli.

By neith. July 23rd, 2010 at 02:01

Thanks ,. Great share about ‘Building ffmpeg for Windows with MSYS and MinGW‘,.

By Tvil. August 14th, 2010 at 16:22


I struggled to compile ffmpeg under MinGW, but the following link helped:

After following the instructions listed under “Main environment”, I could build ffmpeg using this sequence:

cd /ffmpeg/src
./configure –enable-memalign-hack
make install

I then tried to compile the example using the command:

gcc -o avcodec_sample.0.5.0 avcodec_sample.0.5.0.c -g -lavformat -lavcodec -lavutil -lswscale -lm -lwsock32 -lws2_32 -I/local/include/ -L/local/lib/avcodec -L/local/lib/avformat -L/local/lib/ -L/local/lib/avutil

It doesn’t work, I get the following error:

c:/ffmpeg/src/libavformat/utils.c:3196: undefined reference to `av_parse_video_rate’

I’ve tried to include the “avcore” library manually, since it seems that the function is contained in it. I.e. I tried the following command:

gcc -o avcodec_sample.0.5.0 avcodec_sample.0.5.0.c -g -lavcore -lavformat -lavcodec -lavutil -lswscale -lm -lwsock32 -lws2_32 -I/local/include/ -L/local/lib/avcore -L/local/lib/avcodec -L/local/lib/avformat -L/local/lib/ -L/local/lib/avutil

but still got the same error. Any suggestions?


By FFMPEG Watermark video without vhook solution. November 8th, 2011 at 16:34

[...] libavfilter SVN is – svn:// it doesnt seem so complicated anymore oOSo recently ive been playing around with ffmpeg, ive found it quite a useful tool for converting vid…from using an older somewhat functioning version,was that version seemed to fail when converting any [...]