I want to build myself standalone statically linked ffmpeg binaries for Windows from official git source code with MSYS2 environment tools. But every time I get .exe file dynamically linked to mingw libraries that crashes with "The application was unable to start correctly (0xc000007b)" error even if I put required libbz2-1.dll, libiconv-2.dll and libwinpthread-1.dll libraries in it's folder.
I'm running MSYS2 environment with
msys2_shell.cmd -mingw64
line, and use mingw64/mingw-w64-x86_64-gcc 8.2.1+20181214-1 compiler package. Then I run ./configure with
./configure --pkg-config-flags=--static --disable-shared --enable-static
line - the best options I have googled at all my efforts. Then proceed with general
make
make install
sequence.
As a result, I get binaries that run smoothly in MSYS2 environment itself, but when I run it from host Windows explorer or cmd, first of all it ask for libbz2-1.dll, libiconv-2.dll and libwinpthread-1.dll libraries and when I put them in binaries' folder, they crash with "The application was unable to start correctly (0xc000007b)" error.
I've asked about this case at official https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=5&t=6439 forum but still have no response for already 5 days.
Regarding dynamic linking libraries somehow I got bandaid solution with removing *.dll.a files from mingw64\x86_64-w64-mingw32\lib folder. But it looks not very clean for me. I wish to know if it is possible to do static linkage with some compiler/make/linker parameters or with editing ./configure or Makefile files somehow?
Also 0xc000007b error still remaining.
I've managed to have desired result with media-autobuild_suite based on the same MSYS2 environment, so I know it is possible to do this somehow. But I'm very new to all this *nix things so don't understand it's bash script at all, not to mention it is pretty sophisticated by itself. The only thing I see it's producing correct ffmpeg executables running under native Windows environment not requiring dlls listed above.
According to all guides in internet I found at the moment, I should get standalone Windows executables with this toolset, but it just don't work and I'm stuck. Please, help.
I had the same problems. To solve it, I try to disable all external libraries.
My configuration:
--enable-static --enable-gpl --disable-w32threads --disable-autodetect
After compiling, I copy the libwinpthread-1.dll from /mingw64/bin to the binaries' folder. (you can use ldd ffmpeg.exe
to print shared library dependencies)
ffmpeg.exe and ffprobe.exe can run successfully.
using ffmpeg-4.4 & msys2-x86_64-20210419
User contributions licensed under CC BY-SA 3.0