简体   繁体   中英

ffmpeg/libav Linking issue in Windows

I have cross compiled ffmpeg and libav from Linux to Windows (mingw32). So, I've got my .a files and ready to be used for linking in my MSVC2010 project. The thing is that I am getting linking errors and I don't understand why:

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)

Does anybody know what could happen?

You must use C style name mangling when including libav* headers.

extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavcodec/avcodec.h>
...
}

最后我意识到Mingw编译的libs无法从VS2010本机应用程序链接。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM