FFmpeg error LNK2019:无法解析的外部符号avcodec

阅读: 评论:0

FFmpeg error LNK2019:无法解析的外部符号avcodec

FFmpeg error LNK2019:无法解析的外部符号avcodec

关于FFmpeg包错误 LNK2019问题解决方法

错误 LNK2019 无法解析的外部符号 “void __cdecl avcodec_register_all(void)” (?avcodec_register_all@@YAXXZ),该符号在函数 main 中被引用
错误 LNK2019 无法解析的外部符号 “int __cdecl avformat_network_init(void)” (?avformat_network_init@@YAHXZ),该符号在函数 main 中被引用
错误 LNK2019 无法解析的外部符号 “struct AVFormatContext * __cdecl avformat_alloc_context(void)” (?avformat_alloc_context@@YAPEAUAVFormatContext@@XZ),该符号在函数 main 中被引用
错误 LNK2019 无法解析的外部符号 “int __cdecl avformat_open_input(struct AVFormatContext * *,char const *,struct AVInputFormat *,struct AVDictionary * *)” (avformat_open_input@@YAHPEAPEAUAVFormatContext@@PEBDPEAUAVInputFormat@@PEAPEAUAVDictionary@@@Z),该符号在函数 main 中被引用

原因

网上看了很多文章。有说没有lib,dll没有的。还有让我直接注释掉的。我使用的是vs2019+ffmpeg的库。 avcodec_register_all()函数报错。原因是因为这个.h文件原来是用C写的。C++中要是用的话要用下面的方式才可以。

错误代码


#include "myProject.h"
#include <stdio.h> 
#include <Windows.h>
#include "libavformat/avformat.h"
int main()
{AVFormatContext* pFormatCtx;int             i, videoindex;AVCodecContext* pCodecCtx;AVCodec* pCodec;// Initavcodec_register_all(); //注册常用包avformat_network_init();//初始化网络pFormatCtx = avformat_alloc_context();    //分配内存if (avformat_open_input(&pFormatCtx, "rtmp://58.200.131.2:1935/livetv/gxtv", NULL, NULL) != 0) {   printf("Couldn't open input stream.n");return -1;}return 0;
}

正确代码

#include "myProject.h"
#include <stdio.h> 
#include <Windows.h>
#define __STDC_CONSTANT_MACROS#ifdef _WIN32
//Windows
extern "C"
{
#include "libavformat/avformat.h"
};
#else
//
#ifdef __cplusplus
extern "C"
{
#endif
#include <libavformat/avformat.h>
#ifdef __cplusplus
};
#endif
#endifint main()
{AVFormatContext* pFormatCtx;int             i, videoindex;AVCodecContext* pCodecCtx;AVCodec* pCodec;// Initavcodec_register_all(); //注册常用包avformat_network_init();//初始化网络pFormatCtx = avformat_alloc_context();    //分配内存if (avformat_open_input(&pFormatCtx, "rtmp://58.200.131.2:1935/livetv/gxtv", NULL, NULL) != 0) {   printf("Couldn't open input stream.n");return -1;}return 0;
}

本文发布于:2024-02-01 08:25:40,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170674714035223.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:符号   error   FFmpeg   avcodec
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23