title: Need help/instructions to build ffmpeg with libdav1d under Windows
body: <p>I am asking for help because I cannot build ffmpeg with the AV1 decoding library &quot;libdav1d&quot;.</p>
  <p>I am under Windows 10.</p>
  <p>I can build ffmpeg without &quot;libdav1d&quot;. To do so, I use msys 1.0.</p>
  <p>In msys 1.0, I type:</p>
  <pre><code>./configure --target-os=win64 --arch=x86_64 --toolchain=msvc --enable-shared
  make
  </code></pre>
  <p>and it works fine: I can buid ffmpeg in x64 mode. With a slightly different ./configure line, I can also build it in win32 mode.</p>
  <p>But then I try to include libdav1d like this:</p>
  <pre><code>./configure --target-os=win64 --arch=x86_64 --toolchain=msvc --enable-shared --enable-libdav1d
  </code></pre>
  <p>and it fails, with this error message:</p>
  <pre><code>ERROR: dav1d &gt;= 0.5.0 not found using pkg-config
  </code></pre>
  <p>So I tried 2 different approach:</p>
  <ol>
  <li>I downloaded the source code of libdav1d from <a href="https://code.videolan.org/videolan/dav1d" rel="nofollow noreferrer">https://code.videolan.org/videolan/dav1d</a> and I tried to compile it</li>
  <li>I also downloaded the already built libraries (for win 64 and win 32) from <a href="https://code.videolan.org/videolan/dav1d" rel="nofollow noreferrer">https://code.videolan.org/videolan/dav1d</a></li>
  </ol>
  <p>*** Concerning the 1st approach (build libdav1d from its source code), I have seen that I need to install meson, ninja and nasm.</p>
  <p>I have seen somewhere that I should use msys 2.0 to do that, so I install msys 2.0 and run it.</p>
  <p>Then I follow the instructions indicated on <a href="https://code.videolan.org/videolan/dav1d" rel="nofollow noreferrer">https://code.videolan.org/videolan/dav1d</a></p>
  <p>But when I run ninja, I get compilation errors like this :</p>
  <pre><code>$ ninja
  [1/161] Compiling C object src/libdav1d_bitdepth_8.a.p/cdef_tmpl.c.obj
  FAILED: src/libdav1d_bitdepth_8.a.p/cdef_tmpl.c.obj
  &quot;cl&quot; &quot;-Isrc\libdav1d_bitdepth_8.a.p&quot; &quot;-Isrc&quot; &quot;-I..\src&quot; &quot;-I.&quot; &quot;-I..&quot; &quot;-Iinclude\dav1d&quot; &quot;-I..\include\dav1d&quot; &quot;-Iinclude&quot; &quot;-I..\include&quot; &quot;-I..\include\compat\msvc&quot; &quot;-DNDEBUG&quot; &quot;/MD&quot; &quot;/nologo&quot; &quot;/showIncludes&quot; &quot;/W3&quot; &quot;/O2&quot; &quot;-D_POSIX_C_SOURCE=200112L&quot; &quot;-wd4028&quot; &quot;-wd4090&quot; &quot;-wd4996&quot; &quot;-DBITDEPTH=8&quot; &quot;/Fdsrc\libdav1d_bitdepth_8.a.p\cdef_tmpl.c.pdb&quot; /Fosrc/libdav1d_bitdepth_8.a.p/cdef_tmpl.c.obj &quot;/c&quot; ../src/cdef_tmpl.c
  ..\include\common/attributes.h(133) : error C2054: '(' attendu après 'inline'
  ..\include\common/attributes.h(133) : error C2085: 'ctz' : ne figure pas dans la liste de paramètres formels
  ..\include\common/attributes.h(133) : error C2143: erreur de syntaxe : absence de ';' avant '{'
  ..\include\common/attributes.h(139) : error C2054: '(' attendu après 'inline'
  ..\include\common/attributes.h(139) : error C2085: 'clz' : ne figure pas dans la liste de paramètres formels
  ..\include\common/attributes.h(139) : error C2143: erreur de syntaxe : absence de ';' avant '{'
  ..\include\common/attributes.h(152) : error C2054: '(' attendu après 'inline'
  &lt;and many others...&gt;
  </code></pre>
  <p>And when I try to reconfigure meson, I get this error:</p>
  <pre><code>$ meson --reconfigure
  The Meson build system
  Version: 0.59.2
  Source dir: /c/projects/ffmpeg44/dav1d
  Build dir: /c/projects/ffmpeg44/dav1d/build
  Build type: native build
  Project name: dav1d
  Project version: 0.9.2
  C compiler for the host machine: cl (msvc 16.00.40219.01 &quot;Compilateur d'optimisation Microsoft (R) 32�bits C/C++ version�16.00.40219.01 pour 80x86&quot;)
  C linker for the host machine: link link 10.00.40219.01
  
  ../meson.build:25:0: ERROR: Unknown linker(s): [['lib'], ['llvm-lib']]
  The following exception(s) were encountered:
  Running &quot;lib /?&quot; gave &quot;[Errno 2] No such file or directory: 'lib'&quot;
  Running &quot;llvm-lib /?&quot; gave &quot;[Errno 2] No such file or directory: 'llvm-lib'&quot;
  
  A full log can be found at /c/projects/ffmpeg44/dav1d/build/meson-logs/meson-log.txt
  </code></pre>
  <p>I have also tried to copy cl.exe and link.exe from Visual Studio 2010 in the msys 2.0 bin\ folder (replacing the already present link.exe) but I had no success doing that.</p>
  <p>*** Concerning the 2nd approach,  (build libdav1d from its source code), I have seen that I need to install meson, ninja and nasm.</p>
  <p>I download the zip containing the already built libraries of libdav1d from <a href="https://code.videolan.org/videolan/dav1d" rel="nofollow noreferrer">https://code.videolan.org/videolan/dav1d</a></p>
  <p>Then I created a folder ffmpeg/libdav1d and I copied the bin, include\ and lib\ folders from the zip in this ffmpeg/libdav1d folder.</p>
  <p>Then in msys 1.0, I run <code>./configure --target-os=win64 --arch=x86_64 --toolchain=msvc --enable-shared --enable-libdav1d</code></p>
  <p>But then I get this error:</p>
  <pre><code>ERROR: dav1d &gt;= 0.5.0 not found using pkg-config
  </code></pre>
  <p>If I understand correctly, the problem comes from the fact that pkg-config doesn't know where to find dav1d (even if it is in ffmpeg/libdav1d, like the other ffmpeg libraries ffmpeg/libavcodec, ffmpeg/libavdevice, ffmpeg/libavformat, ...)</p>
  <p>So I looked for a solution to tell pkg-config where libdav1d is.</p>
  <p><code>echo $PKG_CONFIG_PATH</code> returns an empty reply</p>
  <p>so I defined the environment variable PKG_CONFIG_PATH as it is defined in my msys 2.0 by typing: <code>export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig</code></p>
  <p>But since these folders don't exist in my msys 1.0, I created this folder (in Windows)</p>
  <pre><code>C:\MinGW\msys\1.0\share\pkgconfig
  </code></pre>
  <p>and in this folder, I copied the file &quot;dav1d.pc&quot; and I modify the first line of this file (the value of variable prefix):</p>
  <pre><code>prefix=/c/projects/ffmpeg44/ffmpeg/libdav1d
  libdir=${prefix}/lib
  includedir=${prefix}/include
  
  Name: libdav1d
  Description: AV1 decoding library
  Version: 0.9.2
  Libs: -L${libdir} -ldav1d
  Cflags: -I${includedir}
  </code></pre>
  <p>But when I use ./configure, I keep having this error message: <code>ERROR: dav1d &gt;= 0.5.0 not found using pkg-config</code></p>
  <p>So could someone give me step by step instructions to build (under Windows) ffmpeg with libdav1d ?</p>
  <p>If possible, I would prefer to build libdav1d and include it in ffmpeg rather than use libdav1d already built by someone else.</p>
  <p>Thanks in advance!</p>