问题描述
我正在尝试围绕libavformat构建一些视频阅读代码.在此处获取编译的DLL和.lib
文件之后,我将构建我的代码和链接器即使我已链接到提供的.lib
文件中,也找不到任何libavformat符号.
I'm attempting to build some video-reading code around libavformat. After getting the compiled DLLs and .lib
files here, I go to build my code, and the linker can't find any of the libavformat symbols even though I've linked in the provided .lib
files.
用dumpbin -headers
检查libavformat.lib
会发现它导出带有下划线前缀的所需功能.例如,当我想调用avformat_open_input
时,.lib文件给出了_avformat_open_input
.
Inspecting libavformat.lib
with dumpbin -headers
reveals that it exports the desired functions with an underscore prefix. For example, while I want to call avformat_open_input
, the .lib file gives _avformat_open_input
.
这是为什么,为什么我不能链接预编译的dll?
Why is this, and why can't I link the precompiled dlls?
推荐答案
您需要完成所有任务,才能将libav
与MSVC++
结合使用.首先转到 Zeranoe
You need to do following all tasks to use libav
with MSVC++
. First goto Zeranoe
- 下载
Shared
版本,从bin
文件夹复制所有.dll
文件,并将它们粘贴到将生成exe
的输出目录中. - 下载
Developer
版本,从lib
文件夹复制所有.lib
文件,并将其粘贴到主c ++文件所在的位置(例如Folder-1\Folder-2
其中Folder-1
具有.sln
文件,因此您必须将Folder-2
中的.lib
个文件) - 从步骤2中下载的
Developer
版本中,复制include
文件夹中的所有目录并将其粘贴到Folder-2中(请参阅步骤2中有关Folder-2的详细信息) - 下载 inttypes.h 和 stdint.h ,将其保存在此位置
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\
文件夹中. - 要包含头文件,请使用以下语法
- Download
Shared
Version, Copy all.dll
files frombin
folder and paste them in the output directory whereexe
will be generated. - Download
Developer
Version, Copy all.lib
files fromlib
folder and paste them with your main c++ file is located (e.g.Folder-1\Folder-2
WhereFolder-1
has the.sln
file so you have to put.lib
files inFolder-2
) - From
Developer
Version you downloaded in Step 2 copy all directories frominclude
folder and paste them in Folder-2 (See details about Folder-2 in step 2) - Download inttypes.h and stdint.h, save it on this location
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\
folder. - To include header files use following syntax
您必须使用此extern
,因为libav
是C
库.
You have to use this extern
because libav
is a C
library.
extern "C" {
#include "libavcodec/avcodec.h"
#include "libavdevice/avdevice.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
#include "libavutil/avutil.h"
}
这篇关于在Visual Studio 2010中链接libavformat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!