building FFmpeg with GCC under Windows: need for detailed how-to

Questions that occur when trying to compile FFmpeg.
Post Reply
diamant
Posts: 3
Joined: Mon Jun 20, 2016 1:47 pm

building FFmpeg with GCC under Windows: need for detailed how-to

Post by diamant » Mon Jun 20, 2016 2:16 pm

Let's write an instruction, for the current versions.
1) download ffmpeg-3.0.2.
2) look at https://ffmpeg.org/platform.html#Windows - find it incomplete and/or obsolete
3) download MinGW from http://mingw-w64.org/doku.php/download/mingw-builds - a small installer, select some of variants and it will download/install
for example, x86_64-5.3.0-win32-seh-rt_v4-rev0, by default it's installed in Program Files
4) download MSYS2 from http://msys2.github.io, install according to instructions from the page
note, it creates wrong shortcuts in Start menu, so to run pacman you can manually start msys2_shell.cmd from msys2 install dir

now, questions:
a) msys2 contains mingw64 dir with subdirs - but with no files; shuold I copy files from Program Files to there?
Or I should install first msys2, then mingw? Or in the same dir?
b) The guide from item 2 mentions mingw64_shell.bat - it's absent, and MinGW-w64 Win64 Shell - it's wrong.

That was all only about installation..

Then building.
How to build? How to configure? What batch or executable to start?

rogerdpack
Posts: 1872
Joined: Fri Aug 05, 2011 9:56 pm

Re: building FFmpeg with GCC under Windows: need for detailed how-to

Post by rogerdpack » Fri Jun 24, 2016 2:04 pm

I recently kind of got a build working with MSYS2

https://trac.ffmpeg.org/wiki/CompilationGuide/MinGW

Anyway what I typically do is cross compile:

https://github.com/rdp/ffmpeg-windows-build-helpers

diamant
Posts: 3
Joined: Mon Jun 20, 2016 1:47 pm

Re: building FFmpeg with GCC under Windows: need for detailed how-to

Post by diamant » Mon Jun 27, 2016 11:09 am

rodgerdpack, thank you!
Meanwhile I've managed to install migw/msys and build ffmpeg. My procedure, in short, was:
1) download and install msys2 from https://msys2.github.io/
2) follow the update/install procedure described on that page - that is call pacman some times with according parameters;
note, at some point in this process I had to correct Start menu msys2 shortcut to .bat file, because the file became .cmd, sth like [path]\msys64\msys2_shell.cmd
3) as https://ffmpeg.org/platform.html#Windows mentions, call
pacman -S make pkgconf diffutils,
but use different name instead of 'pkgconf' because it rejects it, I don't remember exactly, maybe 'pkg-config'
4) also call
pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL

This was enough to complete mingw64/msys2 installation for me.

About building ffmpeg:
1) enter the msys2 command line (invoking .cmd from shortcut).
2) configuring the build is done with calling ./configure batch; its command line switches can be found in its text, or are listed with --help option
3) this is an optional step; the fact is that I wanted to build standalone ffmpeg.exe, without any mingw/msys dll dependencies; to achieve this, I hide (e.g. rename) according .dll.a files, so the linker links libraries statically; the libraries were libpthread.dll.a, libwinpthread.dll.a, libbz2.dll.a, libSDL.dll.a, libz.dll.a and libiconv.dll.a
4) building itself is done with calling 'make'; it also has some options, if necessary.

rogerdpack
Posts: 1872
Joined: Fri Aug 05, 2011 9:56 pm

Re: building FFmpeg with GCC under Windows: need for detailed how-to

Post by rogerdpack » Wed Jun 29, 2016 10:14 pm

diamant wrote:rodgerdpack, thank you!
Meanwhile I've managed to install migw/msys and build ffmpeg. My procedure, in short, was:
1) download and install msys2 from https://msys2.github.io/
2) follow the update/install procedure described on that page - that is call pacman some times with according parameters;
note, at some point in this process I had to correct Start menu msys2 shortcut to .bat file, because the file became .cmd, sth like [path]\msys64\msys2_shell.cmd
3) as https://ffmpeg.org/platform.html#Windows mentions, call
pacman -S make pkgconf diffutils,
but use different name instead of 'pkgconf' because it rejects it, I don't remember exactly, maybe 'pkg-config'
4) also call
pacman -S mingw-w64-x86_64-yasm mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL

This was enough to complete mingw64/msys2 installation for me.

About building ffmpeg:
1) enter the msys2 command line (invoking .cmd from shortcut).
2) configuring the build is done with calling ./configure batch; its command line switches can be found in its text, or are listed with --help option
3) this is an optional step; the fact is that I wanted to build standalone ffmpeg.exe, without any mingw/msys dll dependencies; to achieve this, I hide (e.g. rename) according .dll.a files, so the linker links libraries statically; the libraries were libpthread.dll.a, libwinpthread.dll.a, libbz2.dll.a, libSDL.dll.a, libz.dll.a and libiconv.dll.a
4) building itself is done with calling 'make'; it also has some options, if necessary.
I ran into those libbz2.dll.a files as well, where are there from? Where do you delete them from?
Thanks!

diamant
Posts: 3
Joined: Mon Jun 20, 2016 1:47 pm

Re: building FFmpeg with GCC under Windows: need for detailed how-to

Post by diamant » Thu Jun 30, 2016 9:25 am

libpthread.dll.a and libwinpthread.dll.a were in [msys2 dir]\mingw64\x86_64-w64-mingw32\lib\
and other were in [msys2 dir]\mingw64\lib\

Post Reply