错误 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小时内删除。
留言与评论(共有 0 条评论) |