0
点赞
收藏
分享

微信扫一扫

ffmpeg库在windows下编译出现无法链接的问题的解决方法


问题的现象

1>H264Decode.obj : error LNK2019: 无法解析的外部符号 "struct AVFrame * __cdecl avcodec_alloc_frame(void)" (?avcodec_alloc_frame@@YAPAUAVFrame@@XZ),该符号在函数 "public: int __thiscall CH264Decode::avc_decode_init(int,int)" (?avc_decode_init@CH264Decode@@QAEHHH@Z) 中被引用

1>H264Decode.obj : error LNK2019: 无法解析的外部符号 "int __cdecl avcodec_open(struct AVCodecContext *,struct AVCodec *)" (?avcodec_open@@YAHPAUAVCodecContext@@PAUAVCodec@@@Z),该符号在函数 "public: int __thiscall CH264Decode::avc_decode_init(int,int)" (?avc_decode_init@CH264Decode@@QAEHHH@Z) 中被引用

1>H264Decode.obj : error LNK2019: 无法解析的外部符号 "struct AVCodecContext * __cdecl avcodec_alloc_context(void)" (?avcodec_alloc_context@@YAPAUAVCodecContext@@XZ),该符号在函数 "public: int __thiscall CH264Decode::avc_decode_init(int,int)" (?avc_decode_init@CH264Decode@@QAEHHH@Z) 中被引用

1>H264Decode.obj : error LNK2019: 无法解析的外部符号 "struct AVCodec * __cdecl avcodec_find_decoder(enum CodecID)" 
 

网上的解决方法的总结:

(1)添加:

#ifdef __cplusplus
extern "C"
{
#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "avcodec.lib")
#pragma comment (lib, "avdevice.lib")
#pragma comment (lib, "avfilter.lib")
#pragma comment (lib, "avformat.lib")
#pragma comment (lib, "avutil.lib")
#pragma comment (lib, "swresample.lib")
#pragma comment (lib, "swscale.lib")
};
#endif

(2)仅添加:

    extern “C”

(3)我试了上面两种方法,但是都不行。于是我参考我手头上已有的一个项目:avplayer.。参考他的​​cpp​​文件时如何处理这个无法链接的问题的。它的解决方法与上面类似,但是在写法上有所不同

他的做法是:

#ifdef  __cplusplus
extern "C" {
#endif
#include<.....>
void main()
{
//
/
}

#ifdef __cplusplus
}

把main函数包在宏里面。顺利的解决了问题。

参考网址:

​​http://www.360doc.com/content/13/0502/17/9192936_282472350.shtml​​

​​http://blog.sina.com.cn/s/blog_48dc8a0001017p0u.html​​

了解更多关于《计算机视觉与图形学》相关知识,请关注公众号:

ffmpeg库在windows下编译出现无法链接的问题的解决方法_Windows

下载我们视频中代码和相关讲义,请在公众号回复:计算机视觉课程资料

举报

相关推荐

0 条评论