Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved externals trying to use ffmpeg

Tags:

c++

ffmpeg

linker

I'm trying to use some functions from ffmpeg and am running into resilient linker errors. Here's what I did:

  • Downloaded the latest 32-bit "Dev" build from http://ffmpeg.zeranoe.com/builds/ (i.e. ffmpeg-20130418-git-ee94362-win32-dev)
  • Created a "General - empty" C++ project in Visual Studio 2012 Premium
  • Added the [ffmpeg]/lib folder to Linker -> Input -> "Additional Library Directories"
  • Added "swscale.lib;avutil.lib;avformat.lib;avdevice.lib;avcodec.lib;" to Linker -> Input -> "Additional Dependencies"
  • Added the following under C++ -> General -> Additional Include Directories:
    • [ffmpeg]/include
    • [ffmpeg]/include/libswscale
    • [ffmpeg]/include/libavformat

This is my main.cpp:

#include "avformat.h"

int main()
{
    av_register_all();
} 

This fails with:

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

How can I fix this error?

like image 591
Asik Avatar asked Apr 22 '13 14:04

Asik


1 Answers

As you're using C++, you need to surround your ffmpeg #include statements with extern "C" like this :

extern "C"
{
    #include "avformat.h"
}
like image 125
Roger Rowland Avatar answered Sep 21 '22 13:09

Roger Rowland