I’m trying to use FFmpeg in a C++ project in Visual Studio 2010. I want to include the libraries as statically linked files. Simple programs like libavcodec/api-example.c compile without error and no linker error appears in the error view when starting them. However, a message box shows up after starting the application, saying that avutil-51.dll is missing. Do you have any hints on how to fix that?
I used the latest dev build from http://ffmpeg.zeranoe.com/builds/. Then I specified include as additional include directory, avcodec.lib;avfilter.lib;avformat.lib;avutil.lib as additional dependencies and lib as additional library directory.
With FFmpeg you can either:
You built your project as per item 1 above. You have to use and redistribute the av*.dll dependent files with your binary to have it working.
"Static" on Zeranoe means that libraries are statically linked into binaries like
ffmpeg.exe. Do not confuse this with static.liblibraries that link into your binary. Zeranoe does not provide such.On Zeranoe you will find archives like this:
bin/avcodec-54.dllbin/avutil-51.dlllib/avcodec.liblib/avutil.lib"Shared" archive has FFmpeg built with dynamic link to DLL libraries. "Dev" archive has lib files which you can use in your project to link to them as well in a way that ffmpeg.exe does in shared archive.
So, your Visual Studio project can be as simple as this (browse full source here):
You will extract "Dev" archive into
devsubdirectory of Visual Studio project and you will adddev\includeon the additional include path. This will be sufficient to build the binary, and it will be dependent onav*.dll:This is when you extract the "Shared" archive, and copy DLLs from its
binto the directory of your binary. And your app will work from there:20 Jan 2016 UPDATE: The project in repository is upgraded to Visual Studio 2013 (older VS 2010 code) and checked against current Zeranoe builds. The sample and instructions remain in good standing.
Note that
Win32builds in Visual Studio assume that you use 32-bit files from Zeranoe. To build 64-bit version, download respective files and set up Visual C++ project respectively, to buildx64(or, the best, download both, set up both configurations and configure include/lib paths respectively). Failure to match bitness would result in error, mentioned in the comments below.20 Jul 2021 UPDATE: (pulled from comments below) Zeranoe builds are no longer available. A good and officially endorsed alternative is Windows builds by BtbN. You will need a
(...)-win64-gpl-shared.zipor(...)-win64-lgpl-shared.zipfile for this tutorial.