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 ...
随机推荐
- 在xpage上怎么用jdbc去连接sql server呀
你去http://www.openntf.org/Internal/home.nsf 下載以下對應版本最新控件 XPages Extension Library 這裏面已經包括OSGI功能 OSGI在 ...
- memcache使用方法测试
<?php //php操作memcache的使用测试总结--学习 //1 Memcache::connect; //$memcache = new Memcache; //$memcache-& ...
- 转:关于 OGRE 与 OSG 的简单比较
1 前言 我曾经细致阅读过 OGRE 和 OSG 官方提供的文档,有<Pro OGRE 3D Programming>.OGRE自带手册(manual).王锐老师等翻译的<Ope ...
- uitableview 和UISearchBar 下拉提示结合使用
自定cell的代码 餐厅的实体和餐厅对应控件的frame #import <Foundation/Foundation.h> @class RestaurantFrame; @interf ...
- linux shell 脚本攻略学习20--awk命令入门详解
awk生于1977年,创始人有三个,分别为 Alfred Aho,Peter Weinberger, 和 Brian Kernighan,名称源于三个创始人的姓的首字母. 作用:处理文本文件. awk ...
- kafka负载均衡相关资料收集(一)
key为null时Kafka会将消息发送给哪个分区? 当你编写kafka Producer时, 会生成KeyedMessage对象. 1 KeyedMessage<K, V> keyedM ...
- Asynchronous and non-Blocking I/O 翻译[收藏好文]
http://www.tornadoweb.org/en/stable/guide/async.html Real-time web features require a long-lived mos ...
- java小程序,用java在指定目录或以及子目录中找出同名文件,java File过滤文件名后找同名文件
主要是使用java API“java.io.File”实现 一个简单的类,copy出来,因main方法可直接运行. package com.paic.icore.pams.auto.util; imp ...
- 问题 “No mapping found for HTTP request with URI [/fileupload/upload.do]” 的解决
是因为自己springmvc的配置文件里面不小心删除掉了 <!-- 注解扫描 扫描该包下的注解--> <context:component-scan base-package=&qu ...
- 【java】详解集合
目录结构: contents structure [-] 集合概述 什么是集合 Collection和Map的区别 List和Set的区别 ArrayList和LinkedList的区别 HashSe ...