Search code examples
visual-studiovisual-c++libavcodeclibavformat

VC++ dependencies linking issue?


My project is using some libs of libavcodec on Visual Studio 2010. After updating the libs (replacing the lib and includes from Libav) and resolving all Compiler Errors (after 3 years a few things changed in libavcodec), the project compiles without a problem, but my compiled dll does not work.

I am 99% sure it is some dependency problem. Sure i did not only update the linked libs of my project but also placed the correct new dlls into the build folder.

The strange thing i have never seen is that dependency walker detects totally wrong imports from the different dlls, see image.

enter image description here

As you can see, all linked libs seem to indicate the same imports - functions that those libs just don't export.

The only thing i do in that direction besides specifying the libs in the linker section is including the .h files in my program and then of course use them heavily;-)

extern "C" {   
#include <libavcodec/avcodec.h>    
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>        
#include <libavformat/avformat.h>        
#include <libswscale/swscale.h>
#include <libswresample\swresample.h>
}

What i tried:

  • Make sure the correct libs and headers are used by the project
  • clean the build path, tried debug und release build
  • checked if there are new includes that i may have forgotten to link (this would have ended up in a compiler errror anyways)
  • restart VStudio
  • built a test program that links to the same dlls, there the correct imports are shown automatically
  • compiled with VS 2013, no change at all

Solution

  • Custom building binaries depending upon your current project settings is key to avoiding annoying linker errors like the one your are facing.

    You can use vcpkg.exe from github to build the ffmpeg project and rebuild binaries for x86 or x64 machine.

    After installing vcpkg on your system, goto to the Powershell prompt and enter .\vcpkg install ffmpeg. After completion of installation enter ".\vcpkg integrate install" so that your latest ffmpeg libraries are available for use.