今天使用CMake编译FFmpeg的时候,死活编不过,提示什么“undefined reference to 'av_frame_alloc()”

后来仔细查找,发现是头文件包含错误

错误的代码:

#include <libavutil/frame.h>
#include "IDecoder.h" struct AVCodecContext;
class FFDecoder : public IDecoder{ public:
virtual bool Open(XParameters params);
/** 发送数据到解码队列 */
virtual bool SendPacket(XData pkt);
/** 从解码队列中获取一帧数据 */
virtual XData RecvFrame(); protected:
AVCodecContext *avctx = ;
AVFrame *frame = ; };

解决办法

因为使用的是C++,所以在包含头文件的时候要特别注意,如果要包含的是C语言的头文件,必须用extern "C" 来包裹。比如:

extern "C" {
#include <libavcodec/avcodec.h>
}

我的问题就是直接在头文件中引入了FFmpeg的头文件 #include <libavutil/frame.h> ,但没有用extern "C" 包裹才出错的。正确的做法是使用extern "C" 包裹该头文件。

或者是直接在顶部声明用到的结构体即可。如:

#include "IDecoder.h"

struct AVCodecContext;
struct AVFrame;
class FFDecoder : public IDecoder{ public:
virtual bool Open(XParameters params);
/** 发送数据到解码队列 */
virtual bool SendPacket(XData pkt);
/** 从解码队列中获取一帧数据 */
virtual XData RecvFrame(); protected:
AVCodecContext *avctx = ;
AVFrame *frame = ; };

FFmpeg编译: undefined reference to 'av_frame_alloc()'的更多相关文章

  1. PHP无法编译undefined reference to `libiconv_open

    ./configure --prefix=/usr/local/php52 make时提示:.....................................................e ...

  2. (笔记)Linux线程编译undefined reference to 'pthread_create'

    在使用线程时,使用gcc或arm-linux-gcc编译时,会出现错误:undefined reference to 'pthread_create' 主要是以下两种原因: 1.#include &l ...

  3. PHP7编译错误:php编译undefined reference to `libiconv 错误

    ext/gd/libgd/.libs/gdkanji.o: In function `do_convert’: /root/php-5.2.12/ext/gd/libgd/gdkanji.c:350: ...

  4. codeBlocks编译undefined reference to错误

    是没有把c文件编译进去的原因. 右键项目,选择属性,弹出窗体 然后选择build targets 在最下面有个build target files:中把c文件勾选.点击ok重新编译即可. Code:: ...

  5. Android APP使用NDK编译后的ffmpeg库出现undefined reference to 'posix_memalign'错误

    在android程序中使用NDK编译后的ffmpeg库的时候出现了如下错误: jni/libs/libavutil.a(mem.o): in function av_malloc:libavutil/ ...

  6. ubuntu下调试ffmpeg程序出现undefined reference to pthread_once ,undefined reference to uncompress错误

    Ubuntu(版本16.04)下默认配置编译Ffmpeg(版本4.1.3configure 添加选项--enable-threads),将编译好的ffmpeg库添加到程序 中进行编译出现undefin ...

  7. 【FFMPEG】【ARM-Linux开发】 ffmpeg 静态库使用,undefined reference错误

    原文:http://blog.csdn.net/chinazjn/article/details/7954984 ffmpeg移植到dm365上,遇到undefined reference错误: GA ...

  8. CentOS 6.5 编译 PHP-7 报错:undefined reference to `libiconv_open 无法编译 PHP libiconv

    ./configure --with-mysql=/backup/mysql --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zli ...

  9. (原)编译caffe时提示未定义的引用(undefined reference to)

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5864715.html 参考网址: https://github.com/BVLC/caffe/issu ...

随机推荐

  1. Dom4j完整教程,操作XML教程

    目录 1.DOM4J简介 2.XML文档操作1 2.1.读取XML文档: 2.2.获取根节点 2.3.. 新增一个节点以及其下的子节点与数据 2.4. 写入XML文件 2. 5. 遍历xml节点 2. ...

  2. Fix problems that block programs from being installed or removed

    Follow these steps to automatically repair issues including corrupted registry keys that block you f ...

  3. Safari导入书签

    1.打开Safari 这边safari会自动带出一些关联的浏览器,但如果你要导入的浏览器不在这里的话,就需要看第二步. 2.比如,这里我要从QQ浏览器导入,先打开QQ浏览器. 其他浏览器都类似,找到书 ...

  4. java定时重启电脑程序demo

    下载地址:链接: https://pan.baidu.com/s/1HchKC0-gwDz-VU8eEQQMlw 提取码: 9fur

  5. public-private-protected-默认缺省 的区别

    public 公共,加上这个修饰的属性和方法,可以在程序的任何其它地方访问 . private 私有,和public相反,加上这个修饰的属性和方法,只允许在本类中访问. protected 保护,位于 ...

  6. 【MATLAB】matlabR2010a与vs2010联合编译设置

    在matlab中编译C++程序,首先要配置编译器>> mex -setupPlease choose your compiler for building external interfa ...

  7. zabbix v3.0安装部署

    这篇文章没有写明init的部分要注意 zabbix v3.0安装部署 摘要: 本文的安装过程摘自http://www.ttlsa.com/以及http://b.lifec-inc.com ,和站长凉白 ...

  8. Ubuntu菜鸟入门(十五)—— 安装aras2下载软件

    一.安装arias2 sudo add-apt-repository ppa:t-tujikawa/ppa sudo apt-get update sudo apt-get install aria2 ...

  9. 【SqlServer】SqlServer中Alter语句的使用

    在修改Sql Server表结构时,常用到Alter语句,把一些常用的alter语句列举如下. 1:向表中添加字段 Alter table [表名] add [列名] 类型 2:  删除字段 Alte ...

  10. 【HTML】网页中如何让DIV在网页滚动到特定位置时出现

    用js或者jquery比较好实现.但你要知道,滚动到哪个特定位置,例如滚动到一个标题h3那显示这个div,那么可以用jquery算这个h3距离网页顶部的距离:$("h3").off ...