Build
Build
Build environment for Win10 64bit: (Note type out commands it didnt like it when i
copied them, annoying i know but just for the first pacman things then copy away)
1. Download msys2-x86_64-xxx.exe from http://www.msys2.org/
2. intall msys2 to default path C:\msys64\
3. Run MSYS2
4. execute pacman -Syu (confirm with "y" on prompt)
5, when prompted terminate shell and re-run MSYS2
6. Execute pacman -Su (confirm with "y" on prompt)
7. Run (confirm with "y" on prompts)
pacman -S make
pacman -S diffutils
pacman -S yasm
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-gtk3
pacman -S mingw-w64-i686-gtk3
8. Download http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/pkg-
config_0.23-2_win64.zip
9. Unzip and copy pkg-config.exe to E:\msys64\mingw64\bin
10. Download http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-
config_0.26-1_win32.zip
11. Unzip and copy pkg-config.exe to E:\msys64\mingw32\bin
Windows:
1. Edit win32/Makefile.msc so that it uses -MT instead of -MD, since this is how
FFmpeg is built as well.
2. Edit zconf.h and remove its inclusion of unistd.h. This gets erroneously
included when building FFmpeg.
3. Run nmake -f win32/Makefile.msc.
Alternatively, under \zlib-1.2.11\contrib\vstudio\vc14 there is a VisualStudio
project for building zlib.
I would suggest using VisualStudio as it's easier to change the settings.
For x86, compile the ReleaseWithoutAsm - the asm code seems to be causing a
crash in the openSSL unit tests
For x64, Release version (which includes asm), passed the openSSL unit tests
4. (Only for VS) Once you build the projects will build zlibstat.lib you will need
to rename this to zlib.lib or ffmpeg will not link properly
5. Move zlib.lib, zconf.h, and zlib.h to somewhere MSVC can see.
Linux:
64 bit:
1. ./configure --static --64
2. make
(to check x86/x64 for compiled library version in Linux: "objdump -f libz.a | grep
^architecture")
ARM64 Linux:
1. ./configure --static
2. make
Compile openssl
---------------
1. Grab the OpenSSL sources. (https://www.openssl.org/)
OpenSSL 3.0.5
3. Windows:
a. Download and install Perl.
- Perl. We recommend ActiveState Perl, available from
https://www.activestate.com/ActivePerl. Another viable alternative
appears to be Strawberry Perl, http://strawberryperl.com.
You also need the perl module Text::Template, available on CPAN.
Please read NOTES.PERL for more information.
Note: I recommend Strawberry perl which contains all necessary librarie
Note: while Configure is running, it pops up a window suggesting that nmake is not
in the path, and offering to download dmake. Ignore this message! If you are
running a VS2015/VS2017 command window, as suggested above, nmake is certainly in
your path.
notepad makefile
replace CNF_CFLAGS=/Gs0 /GF /Gy
with CNF_CFLAGS=/Gs0 /GF /Gy /MT /MP
/MT to eliminate the linking to runtime DLLs (like VCRUNTIME140.dll)
/MP for multi-processor compilation - though I haven't seen any build
performance difference than without it
Compile libaom
---------------
2. Windows
a. Run 32/64 bit VC env variable command prompt (depending on configuration
required)
b. mkdir aom_build to hold generated config files and cd into it
c. Generate Visual studio sln
# To build with Visual Studio 2019 for the 32-bit x86 target:
$ cmake path/to/aom -G "Visual Studio 16 2019" -A Win32
Note: VS may hang while building the release "aom" (I had it while building win32).
You can build the dependency projects before "aom"
Move aom.lib, and all header files under path/to/aom/aom (eg, aom_codec.h)to
somewhere MSVC can see.
However to generate pkg-config file aom.pc, will still need to cmake with msys2
$ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="path/to/aom_build_x64" -
DENABLE_SHARED=off -DENABLE_NASM=on ../aom && \
$ make && \
$ make install
$ Move aom.lib under path/to/aom_build_x64/lib
64 bit:
$ git clone --depth 1 https://aomedia.googlesource.com/aom
$ mkdir aom_build
$ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/path/to/aom_build_lnx64"
-DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-flto -O3 -
march=znver2" -DCMAKE_C_FLAGS="-flto -O3 -march=znver2" -DCMAKE_C_FLAGS_INIT="-
flto=8 -static" -DENABLE_NASM=on path/to/aom
$ make
$ make install
CONGRATS!! After all that blood sweat and tears you now have what you actually new
to build FFMPEG. Buckel up kidos this is where the fun begins
Getting source code: (you need to update the version of ffmpeg in the
get_sourcecode script)
1. In this directory:
2. Run E:\msys64\msys2_shell.cmd -mingw64
3. cd /e/dev/ffmpeg
4. run ./get_sourcecode
Note: Msys2 compiled binraies will create dependencies on many dll libraries, you
will have to build static openssl and libaom lib by yourself
Build 64
1. Run E:\msys64\msys2_shell.cmd -mingw64
2. cd /e/dev/ffmpeg
3. ./ffmpeg-build-win release 64
Build 32
1. Run E:\msys64\msys2_shell.cmd -mingw32
2. cd /e/dev/ffmpeg
3. ./ffmpeg-build-win release 32
you should find the following code (32 & 64bit): (for openssl)
------------------------------------------------
For Windows:
Notes: If you get this error: cl.exe is unable to create an executable file. If
cl.exe is a cross-compiler, use the --enable-cross-compile option. Only do this if
you know what cross compiling means. C compiler test failed.
First thing to check is where the cl.exe and link.exe are. Run "which cl.exe"
and "which cl.exe" and make sure its pointing to MSVC if its pointing to msys
either rm the file or rename it.
If that doesnt work look in the log file I had the error in "mslink" with the
error "LINK : fatal error LNK1104: cannot open file 'kernel32.lib'" If this is the
case its having trouble finding your Windows SDK. In the mslink file change
"$LINK_EXE_PATH" $@
For:
"$LINK_EXE_PATH" $@ -verbose -LIBPATH:"C:\Program Files (x86)\Windows Kits\
10\Lib\10.0.22621.0\um\x64" -LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\
10.0.22621.0\ucrt\x64" -LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\
10.0.22621.0\ucrt_enclave\x64"
Replace the paths with a link to your sdk and make sure you have links to um,
ucrt, and ucrt_enclave. When you compile x32 you will need to change the path to
the x32 folders. Note you done need -verbose this just gives you more info
If you get "ERROR: aom >= 1.0.0 not found using pkg-config" when you 100%
followed the steps its because even though you are giving it the path to the aom.pc
file it still doesnt want to work. First thing run pkg-config --libs "aom >= 1.0.0"
and if it finds the
package in the correct directory you are having the same problem as me. Go
into the aom.pc file and make sure that the top of the file the element "prefix" is
an abs path to the directory that has the lib/include/bin for the correct build
type.
CONGRATS you have now built FFMPEG on the 4 diff machines! That was a brutal
process but I hope that these notes made it a little better. Pls add your own notes
so that the next person who was to build it will have slightly less issues
Now lets intagrate this new code! Let me tell you it will be just as much fun :)