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

转载连接:https://blog.csdn.net/jia_zhengshen/article/details/10388019 
问题的现象

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

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值