我已经从Linux到Windows(mingw32)交叉编译了ffmpeg和libav。所以,我已经有了我的.a文件,准备在我的MSVC2010项目中用于链接。问题是我得到链接错误,我不明白为什么:
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avformat_free_context referenced in function "public: int __thiscall Imagsa::RTSPCapture::dumpSync(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &,double *,class std::vector<class Imagsa::MjpegFrame,class std::allocator<class Imagsa::MjpegFrame> > &)" (?dumpSync@RTSPCapture@Imagsa@@QAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@4@PANAAV?$vector@VMjpegFrame@Imagsa@@V?$allocator@VMjpegFrame@Imagsa@@@std@@@4@@Z)
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avio_close referenced in function "public: int __thiscall Imagsa::RTSPCapture::dumpSync(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &,double *,class std::vector<class Imagsa::MjpegFrame,class std::allocator<class Imagsa::MjpegFrame> > &)" (?dumpSync@RTSPCapture@Imagsa@@QAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@4@PANAAV?$vector@VMjpegFrame@Imagsa@@V?$allocator@VMjpegFrame@Imagsa@@@std@@@4@@Z)
1>RTSPCapture.obj : error LNK2019: unresolved external symbol _avcodec_close referenced in function "public: int __thiscall Imagsa::RTSPCapture::dumpSync(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_stringstream<char,struct std::char_traits<char>,class std::allocator<char> > &,double *,class std::vector<class Imagsa::MjpegFrame,class std::allocator<class Imagsa::MjpegFrame> > &)" (?dumpSync@RTSPCapture@Imagsa@@QAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0AAV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@4@PANAAV?$vector@VMjpegFrame@Imagsa@@V?$allocator@VMjpegFrame@Imagsa@@@std@@@4@@Z)
有人知道会发生什么吗?
答案 0 :(得分:2)
包含libav *标题时,必须使用C样式名称修改。
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavcodec/avcodec.h>
...
}
答案 1 :(得分:1)
最后我意识到Mingw编译的libs无法从VS2010本机应用程序链接。