今天使用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. CentOS 7 修改网卡名

    假设原网卡名为eth1, 那么在 /etc/sysconfig/network-scripts/ 目录下,必定会存在一个文件名为ifcfg-eth1,和网卡名对应, 这里假设要修改为eth0. 方法一 ...

  2. RHEL7-Samba共享测试

    Linux<----->windows之间共享 Samba使用2个进程 smb    ip之间的通信用smb  (tcp)       nmb    主机名之间的通信用nmb (netbi ...

  3. PM_LOG

    /**查询所有网元的所有粒度**/ SELECT EMS_PM_LOG_ID, SUBNET_ID, AMOID, NE_TYPE, PO_ID, PO_TABLE, GP_BEGIN_TIME, L ...

  4. 【phpstudy】安装Oracle 客户端 并连接

    参考连接:https://blog.csdn.net/liuquan007/article/details/77508518 phpstudy2016是32位版 phpstudy2014是64位版本[ ...

  5. asiHttpRequst 学习地址

    最全面的地址 http://blog.csdn.net/uxyheaven/article/details/7884734 http://allseeing-i.com/ASIHTTPRequest/ ...

  6. java读取txt字符串挨个写入int数组

    int []num=new int[1001]; FileReader fr = new FileReader("1.txt"); BufferedReader br = new ...

  7. Ubuntu远程桌面,如何退出全屏

    首先安装Linux 下远程桌面客户端软件-rdesktop 打开终端 执行sudo apt-get install rdesktop 远程连接XP 系统(前提是windows xp 必须打开并且允许远 ...

  8. 【DM】The PageRank Citation Ranking: Bringing Order to the Web - PageRank引用排名:将订单带到Web上

    [论文标题]The PageRank Citation Ranking: Bringing Order to the Web (1998) [论文作者]Larry Page [论文链接]Paper(1 ...

  9. solr开发,提交索引数据的几种方式

    今天抽空学习了一下solr,有新东西学习就是哈皮! 期待能有机会与实战.实例仅为个人理解学习实例.提交到Solr服务器上的数据必须是 SolrInputDocument 类型. 方案一:利用反射,自定 ...

  10. Java 内存模型及GC原理 (转载)

    一个优秀Java程序员,必须了解Java内存模型.GC工作原理,以及如何优化GC的性能.与GC进行有限的交互,有一些应用程序对性能要求较高,例如嵌入式系统.实时系统等,只有全面提升内存的管理效率,才能 ...