I'm trying to use some functions from ffmpeg and am running into resilient linker errors. Here's what I did:
我正在尝试使用ffmpeg中的一些函数,并遇到了弹性链接器错误。这是我所做的:
- Downloaded the latest 32-bit "Dev" build from http://ffmpeg.zeranoe.com/builds/ (i.e. ffmpeg-20130418-git-ee94362-win32-dev)
- 从http://ffmpeg.zeranoe.com/builds/(即ffmpeg-20130418-git-ee94362-win32-dev)下载最新的32位“Dev”。
- Created a "General - empty" C++ project in Visual Studio 2012 Premium
- 在Visual Studio 2012 Premium中创建了一个“通用-空”c++项目
- Added the [ffmpeg]/lib folder to Linker -> Input -> "Additional Library Directories"
- 将[ffmpeg]/lib文件夹添加到Linker ->输入->“附加库目录”
- Added "swscale.lib;avutil.lib;avformat.lib;avdevice.lib;avcodec.lib;" to Linker -> Input -> "Additional Dependencies"
- 添加“swscale.lib;avutil.lib;avformat.lib;avdevice.lib;avcodec.lib;”到链接器->输入->“附加依赖项”
- Added the following under C++ -> General -> Additional Include Directories:
- [ffmpeg]/include
- ffmpeg /包括
- [ffmpeg]/include/libswscale
- ffmpeg / include / libswscale
- [ffmpeg]/include/libavformat
- ffmpeg / include / libavformat
- 在c++ ->通用->附加目录下增加以下内容:[ffmpeg]/ Include [ffmpeg]/ Include /libswscale [ffmpeg]/ Include /libavformat
This is my main.cpp:
这是我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
错误LNK2019:未解决的外部符号“void __cdecl av_register_all(void)”(av_register_all@yaxxz)在函数_main中引用。
How can I fix this error?
我如何修正这个错误?
1 个解决方案
#1
22
As you're using C++, you need to surround your ffmpeg #include
statements with extern "C"
like this :
当您使用c++时,您需要将ffmpeg #include语句括起来,使用如下形式的extern "C"语句:
extern "C"
{
#include "avformat.h"
}
#1
22
As you're using C++, you need to surround your ffmpeg #include
statements with extern "C"
like this :
当您使用c++时,您需要将ffmpeg #include语句括起来,使用如下形式的extern "C"语句:
extern "C"
{
#include "avformat.h"
}