FFmpeg编译: undefined reference to 'av_frame_alloc()'
今天使用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()'的更多相关文章
- PHP无法编译undefined reference to `libiconv_open
./configure --prefix=/usr/local/php52 make时提示:.....................................................e ...
- (笔记)Linux线程编译undefined reference to 'pthread_create'
在使用线程时,使用gcc或arm-linux-gcc编译时,会出现错误:undefined reference to 'pthread_create' 主要是以下两种原因: 1.#include &l ...
- 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: ...
- codeBlocks编译undefined reference to错误
是没有把c文件编译进去的原因. 右键项目,选择属性,弹出窗体 然后选择build targets 在最下面有个build target files:中把c文件勾选.点击ok重新编译即可. Code:: ...
- Android APP使用NDK编译后的ffmpeg库出现undefined reference to 'posix_memalign'错误
在android程序中使用NDK编译后的ffmpeg库的时候出现了如下错误: jni/libs/libavutil.a(mem.o): in function av_malloc:libavutil/ ...
- ubuntu下调试ffmpeg程序出现undefined reference to pthread_once ,undefined reference to uncompress错误
Ubuntu(版本16.04)下默认配置编译Ffmpeg(版本4.1.3configure 添加选项--enable-threads),将编译好的ffmpeg库添加到程序 中进行编译出现undefin ...
- 【FFMPEG】【ARM-Linux开发】 ffmpeg 静态库使用,undefined reference错误
原文:http://blog.csdn.net/chinazjn/article/details/7954984 ffmpeg移植到dm365上,遇到undefined reference错误: GA ...
- 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 ...
- (原)编译caffe时提示未定义的引用(undefined reference to)
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5864715.html 参考网址: https://github.com/BVLC/caffe/issu ...
随机推荐
- Spring Cloud Edgware SR3 让Zuul支持形如 /xxx和/xxx/yyy 格式的路径配置
在包路径:org.springframework.cloud.netflix.zuul.filters 下,新建类SimpleRouteLocator,取代jar包中的类.内容如下: /* * Cop ...
- 51单片机——My-Clock项目
技术:51单片机.光敏传感器.PCF8591.DHT11.DS1302.OLED显示屏 概述 项目My-Clock是一个环境监测时钟,接入光敏传感器和温湿度传感器监测环境信息,加入DS1302模块 ...
- windows常用命令行整理
Windows虽然以GUI界面为主,但有时命令行也起到了很大的作用,下面就介绍几个常用.常见的windows命令行命令 1.ping 功能:用来测试数据包能否通过IP协议到达特定主机.即测试本机与特定 ...
- 【centos6】安装redis + phpredis 以及 常用配置参数
1.redis-server和redis-cli安装文章:http://www.cnblogs.com/skyessay/p/6429988.html 1.前置条件:查看是否安装gcc,命令:gcc ...
- error LNK2019: 无法解析的外部符号 __vsnwprintf,该符号在函数 "long __stdcall StringVPrintfWorkerW
答案就是链接:legacy_stdio_definitions.lib 这个lib即可
- Xcode之断点调试
断点类型: 1.异常断点 异常断点是代码出现问题导致编译器抛出异常时触发的断点.它在断点导航器中设置.点击+号,选择Exception Breakpoint选项.如下图3-1所示 Exception选 ...
- 完善_IO, _IOR, _IOW, _IOWR 宏的用法与解析
_IO, _IOR, _IOW, _IOWR 宏的用法与解析 原文地址:http://www.eefocus.com/ayayayaya/blog/12-03/245777_20cdd.html 作 ...
- librbd 分析
一.概述
- C# WinForm开发系列 - DataGrid/DataGridView
在WinForm开发中,DataGrid/DataGridView被广泛使用于绑定数据库中数据进行呈现.整理一些关于DataGrid/DataGridView使用的文章,涉及DataGrid/Data ...
- 【Hibernate】数据Session对象的常规操作收集
因为Hibernate是ORM(对象关系映射)的,所以程序员是不需要写Sql语句的.所有的操作都是通过对对象的操作. 1,原生Session 事务管理 Transaction tx = session ...