Unresolved externals trying to use ffmpeg

I am trying to use some functions from ffmpeg and am in persistent linker errors. Here is what I did:

  • I downloaded the latest 32-bit build "Dev" from http://ffmpeg.zeranoe.com/builds/ (that is, ffmpeg-20130418- git -ee94362-win32- DEV)
  • Created the project "General - empty" C ++ in Visual Studio 2012 Premium
  • Added [ffmpeg] / lib folder in Linker β†’ Input β†’ "Additional Library Directories"
  • Added "swscale.lib; avutil.lib; avformat.lib; avdevice.lib; avcodec.lib;" to Linker β†’ Input β†’ "Additional Dependencies"
  • In C ++, the following has been added:> General β†’ Additional Include Directories:
    • [Ffmpeg] / enable
    • [Ffmpeg] / enable / libswscale
    • [Ffmpeg] / enable / libavformat

This is my main.cpp:

#include "avformat.h" int main() { av_register_all(); } 

This fails:

error LNK2019: unresolved external symbol "void __cdecl av_register_all (void)" (? av_register_all @@ YAXXZ) referenced in the _main function

How can I fix this error?

+7
source share
1 answer

When you use C ++, you need to surround your ffmpeg #include statements with extern "C" as follows:

 extern "C" { #include "avformat.h" } 
+22
source

All Articles