qt 工程添加 ffmpeg(undefined reference to av_register_all() 和 “UINT64_C” was not declared in this scope)
来源:互联网 发布:可爱锁骨链韩版淘宝 编辑:程序博客网 时间:2024/06/07 00:20
前提是 已经安装好qt 环境
步骤一:
到ffmpeg官网 下载 win平台 编译好的 shared+dev 版本的开发包,获取到 ffmpeg的头文件和 lib ,dll
步骤二:
添加ffmpeg 头文件和lib到qt 工程
INCLUDEPATH += $$PWD/../../commonlib/ffmpeg-dev/include
DEPENDPATH += $$PWD/../../commonlib/ffmpeg-dev/include
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lavformat
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lavdevice
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lavcodec
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lavfilter
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lavutil
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lpostproc
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lswresample
LIBS += -L$$PWD/../../commonlib/ffmpeg-dev/lib -lswscale
步骤三:
在需要使用ffmepg 的地方添加相关的头文件,如下
extern "C"{
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
# include <stdint.h>
#endif
#include"libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "libavutil/imgutils.h"
}
int main(int argc, char *argv[])
{
AVFormatContext *pFormatCtx;
int i, videoindex;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame,*pFrameYUV;
unsigned char *out_buffer;
AVPacket *packet;
int ret, got_picture;
av_register_all();
return 0;
}
注意的地方是,因为ffmpeg是纯c编译的,qt配置的是C++编译器,所以自如没有加上“extern "C" 的话,会提示 undefined reference to av_register_all() 和 出现“UINT64_C” was not declared in this scope 的错误;
ps C++保留了一部分过程试语言的特点,因而它可以定义不属于任何类的全局函数和变量,但是C++毕竟是一种面向对象的程序设计语言,为了支持函数的重载,c++对全局函数的处理明显与C不同。
extern "c" 的主要作用就是为了能够正确实现c++代码调用其他C语言代码,加上extern "C" 后,会提示编译器这部分的代码按c语言进行编译 ,而不是 c++的,由于c++支持函数重载,因而编译器编译函数的过程会将函数的参数类型也加到编译后的代码中,而不仅仅是函数名;而c语言并不支持函数重载,因而编译c语言代码的函数不会带上函数的参数类型,一般只包括函数名。
比如说你用c开发了一个dll库,为了能够让c++语言也能调用你的dll输出(export)的函数,你需要用 extern ”c“ 来强制编译器不要修改你的函数名
步骤四:
把ffmepg 的dll 放到运行的bin目录中
0 0
- qt 工程添加 ffmpeg(undefined reference to av_register_all() 和 “UINT64_C” was not declared in this scope)
- ffmpeg: ‘UINT64_C’ was not declared in this scope
- ffmpeg: ‘UINT64_C’ was not declared in this scope
- ffmpeg: ‘UINT64_C’ was not declared in this scope
- ffmpeg: ‘UINT64_C’ was not declared in this scope
- ffmpeg: 'UINT64_C' was not declared in this scope
- ffmpeg中遇到UINT64_C’ was not declared in this scope
- ffmpeg中遇到UINT64_C’ was not declared in this scope
- ffmpeg: 'UINT64_C' was not declared in this scope
- ffmpeg中遇到UINT64_C’ was not declared in this scope
- ffmpeg中遇到UINT64_C’ was not declared in this scope
- 'UINT64_C' was not declared in this scope
- ‘UINT64_C’ was not declared in this scope
- FFmpeg:'UINT64_C' was not declared in ths scope
- linux 编译ffmpeg 出错:error: 'UINT64_C' was not declared in this scope
- linux 编译ffmpeg 出错:error: 'UINT64_C' was not declared in this scope
- android NDK编译ffmpeg错误 'UINT64_C' was not declared in this scope的解决
- error: 'UINT64_C' was not declared in this scope
- HMM-Computing Acoustic Likelihoods
- 如何实现页面在线预览PDF文档
- 令仔学多线程系列(一)----同步工具类CountDownLatch
- 全景视频的跟踪与合成方法
- 树形结构的sql语句
- qt 工程添加 ffmpeg(undefined reference to av_register_all() 和 “UINT64_C” was not declared in this scope)
- MVP实战心得(四)---封装优化,拆分Toolbar与ContentView
- 接口测试九(fiddler)
- Redis+Spring缓存实例(Windows10环境,附实例源码详解)
- 数据结构与算法总结
- Update Statistics用法
- MongoDB权威指南学习笔记(1)—简介
- PHP微信柏拉图性格标签生成器源码
- 2017/2/23 Java SpringAOP拦截Service实现日志管理(自定义注解)