I build static FFmpeg libs for Windows 64 bit. Configuring as follows:
./configure --disable-everything --enable-static --disable-shared --enable-memalign-hack --disable-debug --enable-stripping --enable-protocol=file --enable-yasm --enable-decoder=mp3,mpeg4,h264 --enable-muxer=mp4,avi --enable-encoder=mjpeg
.
The application is built in Visual Studio 2012 with /MT
option and linked with libavformat.a
, libavcodec.a
etc. I also link it with libmingwex.a
, libgcc.a
.
The linker fails with the following errors:
6>libavformat.a(file.o) : error LNK2001: unresolved external symbol __imp__wrmdir
6>libavformat.a(file.o) : error LNK2001: unresolved external symbol __imp__rmdir
6>libavformat.a(file.o) : error LNK2001: unresolved external symbol __imp__wunlink
6>libavformat.a(file.o) : error LNK2001: unresolved external symbol __imp__unlink
6>libavutil.a(time.o) : error LNK2001: unresolved external symbol clock_gettime
6>libavutil.a(time.o) : error LNK2001: unresolved external symbol nanosleep
As for the 2 latter errors, I can solve them by manually defining macros in config.h
: #define HAVE_NANOSLEEP 1
and #define HAVE_CLOCK_GETTIME 1
.
The question is how to solve the former 4. These look like functions imported from a dll (__imp
prefix), but my application is built with /MT
, and I don't want any dynamic dependencies in FFmpeg. How to get rid of them?
I tried to configure FFmpeg with --extra-cflags="-static"
, but it doesn't help.
It turns out that it is possible now to build FFmpeg with Visual Studio tool chain, natively. So all the MinGW-related issues are not relevant anymore.
For pre-2013 VS versions, which do not have a decent support of C99, it's required to download c99wrap.exe, c99conv.exe, and inttypes.h. Then open Visual Studio native x64 Command Prompt (so that the VC tool chain and the headers are on the search path), and invoke ./configure --toolchain=msvc
and make
.