在Visual Studio的C ++ 2010项目中使用ffmpeg静态库 [英] Using ffmpeg static libraries in an visual studio explress C++ 2010 project
问题描述
正如标题所示,我一直在试图让ffmpeg / libav库在MSVC ++ 2010中工作。
然而,我在调试模式下编码时仍然在运行下面的错误。
As the title says, I have been trying to get ffmpeg/libav libraries to work in MSVC++ 2010. However, I keep running in the following error while coding on debug mode.
代码:
extern "C"
{
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif
#include <libavcodec\avcodec.h>
#include <libavformat\avformat.h>
#include <libswscale\swscale.h>
#include <libavutil\avutil.h>
}
int main( int argc, char* argv[] )
{
av_register_all();
return 0;
}
console:
1>------ Build started: Project: ffmpeg, Configuration: Debug Win32 ------
1>ffmpeg.obj : error LNK2019: unresolved external symbol _av_register_all referenced in function _main
1>C:\Users\okki\documents\visual studio 2010\Projects\ffmpeg\Debug\ffmpeg.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我使用 zeranoe的最新版本git-56ba331(2013-05-14)。
I used zeranoe's latest build git-56ba331 (2013-05-14).
我试过下面的方法来修复这个问题:
And I have tried the following to fix this:
- 将项目配置为查找x64和x86库。
- 将共享包中的DLL添加到这两个库文件夹。 / li>
- 将库目录添加到链接器选项和VC ++目录中。
在这一段时间,任何建议可以帮助。
如果需要任何额外的信息,我会很乐意提供。
I have been stuck on this for a while, and any suggestion can help. If any extra info is needed I will happily provide.
推荐答案
从 http://ffmpeg.zeranoe.com/builds/win32/shared/ 和从 http://ffmpeg.zeranoe.com/builds/win32/dev/ (Shared and Dev)并解压缩它们分别插入 ffmpeg \shared
和 ffmpeg\dev
Download latest files from http://ffmpeg.zeranoe.com/builds/win32/shared/ and from http://ffmpeg.zeranoe.com/builds/win32/dev/ (Shared and Dev) and unpacked them into ffmpeg\shared
and ffmpeg\dev
respectively
创建一个新的控制台项目,将Additional Include Directory的值设置为 ffmpeg\dev\include
,其他库目录为 ffmpeg\dev\lib\
Create a new console project, set the value of "Additional Include Directory" to ffmpeg\dev\include
, "Additional Library Directories" to ffmpeg\dev\lib\
添加到您的代码
# pragma comment (lib, "avformat.lib")
(在实际项目中,至少需要文件 avutil.lib
, avcodec.lib
)
(In real projects you will need at least the files avutil.lib
, avcodec.lib
)
要运行该程序,请从 ffmpeg\shared \bin中复制
到输出文件夹 *。dll
To run the program, copy the *.dll
files from the ffmpeg\shared\bin
to output folder
这篇关于在Visual Studio的C ++ 2010项目中使用ffmpeg静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!