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.添加:



 
 
  1. #ifdef __cplusplus
  2. extern "C"
  3. {
  4. #pragma comment (lib, "Ws2_32.lib")
  5. #pragma comment (lib, "avcodec.lib")
  6. #pragma comment (lib, "avdevice.lib")
  7. #pragma comment (lib, "avfilter.lib")
  8. #pragma comment (lib, "avformat.lib")
  9. #pragma comment (lib, "avutil.lib")
  10. #pragma comment (lib, "swresample.lib")
  11. #pragma comment (lib, "swscale.lib")
  12. };
  13. #endif
2.仅添加:

extern “c”

3.我试了上面两种方法,但是都不行。于是我参考我手头上已有的一个项目:avplayer.。参考他的cpp文件时如何处理这个无法链接的问题的。

它的解决方法与上面类似,但是在写法上有所不同

他的做法是:


 
 
  1. #ifdef __cplusplus
  2. extern "C" {
  3. #endif
  4. #include<.....>
  5. void main()
  6. {
  7. //
  8. /
  9. }
  10. #ifdef __cplusplus
  11. }
  12. #endif

把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、付费专栏及课程。

余额充值