DEV Community

Cover image for Installing MinGW W64 with FFMPEG on Windows and fixing the weird "file downloaded incorrectly" error.
Code Something
Code Something

Posted on

Installing MinGW W64 with FFMPEG on Windows and fixing the weird "file downloaded incorrectly" error.

So guys ๐Ÿ™‚ MinGW-w64 is a library you might come across as a dependency to some other software you're installing.

It appears to have grown in popularity over the years, despite the fact that it seems like the official ORG website has been outdated for quite some time.

MinGW is a dependency for many other computer programs in wide use, such as FFmpeg (for encoding files in video format) which is what I needed to install it for.

And since I had to install MinGW on my Windows PC for just that very purpose (encoding and saving videos in different file formats) I decided to do a write up.

You may have found this MinGW setup article for a completely different reason and I can totally understand it! Still the MinGW-w64 installation process will be similar.

Below what I found was probably the best MinGW installation video. So there is this bug or just some admin rights issue, but many devs (myself included) stumbled over "File Has Been Downloaded Incorrectly" error. And this video helps solve it.

(How to install MinGW W64 on Windows and fix the dreaded "File has been downloaded incorrectly" setup error.)

If you're someone who learns better from visual instructions, it's probably a good idea to watch this MinGW video first.

But the battle isn't over yet. For me, I also had to install it together with FFmpeg. And if that's what you're trying to do, here's the entire list of step by step instructions I've composed in my notes:

Installing MinGW for use with FFMpeg

For those like me, who are installing FFMpeg, here's a more detailed setup process:

  1. Download the latest msys2 installer from http://msys2.org/ and run it.
  2. Follow the instructions on the screen to complete the installation.
  3. Start msys2 by double-clicking on the shortcut created in your start menu or desktop.
  4. In the msys2 shell, update the package repositories with the following command:

pacman -Syu

  1. Exit the msys2 shell and restart it.
  2. In the msys2 shell, install mingw w64 with one of the following commands:

pacman -S mingw-w64-i686-toolchain

or

pacman -S mingw-w64-x86_64-toolchain

  1. You can now find the mingw w64 compiler binaries in the /mingw32/bin and /mingw64/bin directories.

  2. In the msys2 shell, install cmake with the following command:

pacman -S cmake

  1. In the msys2 shell, install make with the following command:

pacman -S make

  1. In the msys2 shell, install git with the following command:

pacman -S git

  1. In the msys2 shell, install vim with the following command:

pacman -S vim

  1. You can now find the cmake, make, and git binaries in the /usr/bin directory.
  2. In the msys2 shell, change to the directory where you want the FFmpeg source code to be downloaded. For example:

cd /c/ffmpeg-source

  1. In the msys2 shell, clone the FFmpeg git repository with the following command:

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg

  1. This will create a directory named ffmpeg in the current directory, which contains the FFmpeg source code.
  2. In the msys2 shell, change to the newly created ffmpeg directory:

cd ffmpeg

  1. Run the following command to configure FFmpeg for building:

./configure --enable-shared --disable-static --disable-debug --disable-doc

  1. Run the following command to build FFmpeg:

make -j4

  1. Run the following command to install FFmpeg:

make install

  1. This will build and install FFmpeg into your msys2 installation directory, which is typically C:\msys64\usr. Notice that weโ€™re not using sudo here, because we installed FFmpeg into our own directory, not into a system directory.
  2. You can check that FFmpeg was installed correctly by running the following command:

ffmpeg -version

You should see output similar to the following:

ffmpeg version 0.10.15-6:0.10.15-1~deb7u1, Copyright (c)

Phew! Finally.

So this is pretty much why I wrote this article, to document the process and hopefully it helps someone going through the same ๐Ÿ™‚

Oh and in some cases you might also want to install MinGW with MSYS2. (because there is a way to install it without MSYS2, but this case is probably a lot more rare for devs.)

Installing MinGW-w64 With MSYS2

You can install the MSYS2 MinGW-w64 compiler toolchain on your system without using MSYS2 by following these instructions:

  1. Download and install the MSYS2 base installer from https://www.msys2.org/.
  2. Start the MSYS2 MinGW-w64 shell from the start menu.
  3. Run pacman -S mingw-w64-x86_64-toolchain to install the toolchain.
  4. Run pacman -S mingw-w64-x86_64-cmake to install CMake.
  5. Follow the instructions in the README to build your software.
  6. When you're done, close the MSYS2 MinGW-w64 shell.

Installing MinGW-w64 Without MSYS2

You can also use the MSYS2 MinGW-w64 compiler toolchain from the command line without using MSYS2 by following these instructions:

  1. Download and install the MSYS2 base installer from https://www.msys2.org/.
  2. Start the MSYS2 MinGW-w64 shell from the start menu.
  3. Run pacman -S mingw-w64-x86_64-toolchain to install the toolchain.
  4. Follow the instructions in the README to build your software.
  5. When you're done, close the MSYS2 MinGW-w64 shell.

Top comments (0)