我使用mingw32工具链从Debian交叉编译了FFMPEG。编译结果是一组 .a 文件。当我尝试在我的项目中使用它们时,我会遇到链接器错误,具体是以下几个:
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avformat_free_context referenced in function ...
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avio_close referenced in function ...
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avcodec_close referenced in function ...
(and much more...)
我已经包含了这样的头文件:
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
}
我使用像这样的.a文件:
#pragma comment(lib, "libavcodec.a")
#pragma comment(lib, "libavformat.a")
#pragma comment(lib, "libavutil.a")
我可以知道为什么我仍然会收到链接器错误吗?最好的问候,
编辑:我意识到这是不可能的。那么,考虑到我无法在Windows中编译ffmpeg,我应该如何在我的MSVC2010项目中使用FFMPEG库?这似乎真的很难......
答案 0 :(得分:2)
GCC(MinGW使用的编译器)没有VisualC ++用来添加库的#pragma
。使用-l
选项进行链接时,您必须手动添加库:
$ gcc objectfile1.o objectfile2.o -o executable -lavcodec -lavformat -lavutil
答案 1 :(得分:1)
最后我意识到mingw编译的libs无法在VS2010本机应用程序中链接。