iTranslated by AI
Building libavif on Windows
Environment Setup
You need three tools: CMake, Ninja, and NASM, so install them.
winget install NASM.NASM Kitware.CMake
For Ninja, download ninja-win.zip from GitHub, extract it, place ninja.exe in an appropriate folder, and add it to your PATH.[1]
nasm --version
clang --version
ninja --version
It is successful if the version information is output after entering the commands above.
Build
Basically, you can just run the commands as described in the GitHub README.
However, at the time of writing, the file that should be generated as .\ext\libwebp\build\libsharpyuv.lib is instead generated as .\ext\libwebp\build\sharpyuv.lib, causing subsequent CMake steps to fail. Therefore, I am using the ren command to rename it.
All other commands are the same as those written in the README.
git clone -b v1.0.3 https://github.com/AOMediaCodec/libavif.git
cd libavif/ext
./aom.cmd
./libyuv.cmd
./libsharpyuv.cmd
./libjpeg.cmd
./zlibpng.cmd
cd ..
ren .\ext\libwebp\build\sharpyuv.lib libsharpyuv.lib
cmake -S . -B build -DBUILD_SHARED_LIBS=OFF -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_AOM=ON -DAVIF_LOCAL_LIBYUV=ON -DAVIF_LOCAL_LIBSHARPYUV=ON -DAVIF_LOCAL_JPEG=ON -DAVIF_LOCAL_ZLIBPNG=ON -DAVIF_BUILD_APPS=ON
cmake --build build --parallel
aom.lib is generated under .\ext\aom\build.libavif, and avif.lib is generated under .\build\Release.
Additionally, you can generate avifenc.exe and avifdec.exe with the following command:
msbuild ".\build\libavif.sln" /m /verbosity:minimal /p:Configuration=Release
-
Technically,
winget install Ninja-build.Ninjashould work, but it failed in my environment, so I'm using the manual installation method. ↩︎
Discussion