Just to close the loop on this, I wasn't happy with mingw-w64 for my purposes, specifically because it lacks a useful implementation of libscrnsave
. So instead I built libav
from source using standard mingw
.
Building libav
was fairly simple, once I figured it all out. It goes like this:
- Download and install the mingw installer from http://www.mingw.org/.
- Use the mingw installer to install MSYS.
- Download yasm from http://yasm.tortall.net/Download.html
- Renamed the downloaded yasm executable to just
yasm.exe
, and place it in the MSYS directory, under bin
.
- Download the libav sources from https://libav.org/download.html
- Unpack the libav sources.
- Open MSYS and
cd
to wherever the libav sources are.
- In MSYS, run
./configure --disable-pthreads --disable-w32threads --prefix=/c/apps/pf/libav
(those are the options that worked for me, the --prefix
option specifies where to install the libraries when you run make install
, mine places them under C:\apps\pf\libav
).
- Once that completes, run
make
, then make install
.
Once the libraries were built, I was able to link against them building from the normal windows command line using standard mingw.
To use with pkg-config
, you need to add the lib/pkgconfig
directory under the installed location to the PKG_CONFIG_PATH
env variable. To properly build, you should use pkg-config <LIBS> --cflags --libs
to get the correct flags to pass to gcc
, where <LIBS>
is the list of libav libraries you need to build against. It doesn't do any harm to just include all of the libav libraries, but order matters. The following order seems to work for me: libavdevice libavformat libavcodec libavfilter libswscale libavresample libavutil
.
Ultimately, the command line I used that worked looked like this (line continuation and comments added):
#Compile
gcc -o decoding_encoding.obj -c -IC:\apps\pf\libav\include decoding_encoding.c
#Link
gcc -o decoding_encoding.exe decoding_encoding.obj -LC:\apps\pf\libav\lib \
-lavdevice -lavfilter -lavformat -lavcodec -lswscale -lavresample \
-lavicap32 -lws2_32 -lpsapi -ladvapi32 -lshell32 -lavutil -lm