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?
Answer
As you're using C++, you need to surround your ffmpeg #include
statements with extern "C"
like this :
extern "C"
{
#include "avformat.h"
}
No comments:
Post a Comment