Skip to content

Instantly share code, notes, and snippets.

@nguditi
Created June 1, 2021 05:55
Show Gist options
  • Save nguditi/27c81a205cc5e7697984c0d3ecf026ad to your computer and use it in GitHub Desktop.
Save nguditi/27c81a205cc5e7697984c0d3ecf026ad to your computer and use it in GitHub Desktop.
Build FFmpeg static lib in Window using MSYS2 and MSVC 2017
It's take two day searching and trying to firgure out the correct way =)))
follow https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
-------BUT IT'S NOT WORK--------
1. Make sure SET LIB ; SET LIBPATH ; SET INCLUDE with exist and right path(version, exist binary files...)
2. Make sure evironment path, environment variables point to right value/path.
--------If still cannot build, follow my way---------
1. Follow MSYS2 Setup in https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
2. Make sure add PATH C:\msys64\ in environment system variable to run msys2_shell.cmd everywhere
3. Edit C:/msys64/msys2_shell.cmd
Add these line below the "setlocal (or setlocal EnableDelayedExpansion line)"
call "%VS150COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" x86 store
set LIB=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\lib\x86;%UniversalCRTSdkDir%Lib\%UCRTVersion%\ucrt\x86;%UniversalCRTSdkDir%Lib\%UCRTVersion%\um\x86;
set LIBPATH=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\lib\x86;
set INCLUDE=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\include;%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTVersion%\ucrt;%UniversalCRTSdkDir%Include\%UCRTVersion%\um;%UniversalCRTSdkDir%Include\%UCRTVersion%\shared;%UniversalCRTSdkDir%Include\%UCRTVersion%\winrt;
4. Make sure SET LIB ; SET LIBPATH ; SET INCLUDE above are OK(version, exist binary files...)
also %VS150COMNTOOLS% environment variable point to right dir.
5. Maybe you also need to add system environment PATH C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86
6. Open cmd.exe and call msys2_shell.cmd -use-full-path (it will pass above config to msys instance)
7. In msys terminal, cd to ffmpeg and call your configure/make/make install
Here is my example configure
--configure.sh file--
#!/bin/sh
./configure \
--toolchain=msvc \
--arch=x86 \
--target-os=win32 \
--extra-cflags="-MD -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WIN32_WINNT=0x0A00" \
--extra-ldflags="-APPCONTAINER WindowsApp.lib" \
--disable-d3d11va \
--disable-dxva2 \
--disable-doc \
--disable-programs \
--disable-ffplay \
--disable-ffprobe \
--disable-ffmpeg \
--disable-bzlib \
--disable-libopenjpeg \
--disable-iconv \
--disable-zlib \
--disable-debug \
--disable-filters \
--disable-everything \
--enable-static \
--enable-cross-compile \
--enable-x86asm \
--enable-decoder=hevc \
--enable-decoder=h264 \
--enable-decoder=mpeg4*,mp3*,aac*,ac3*,opus,vorbis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment