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 ...
随机推荐
- Mingw编译DLib
Mingw编译DLib 因为机器上安装了qt-opensource-windows-x86-mingw530-5.8.0,所以准备使用其自带的mingw530来编译DLib使用. 因为DLib使用CM ...
- iteye-Spring的缺点有哪些
http://www.iteye.com/topic/1126929 1. flounders -- 发表时间:2012-09-25 如题,希望大侠们指出,不能用Spring就觉得他什么都好, ...
- Ubuntu 12.04安装VMware Workstation8.0.3
2012-06-18 12:52 Ubuntu安装VMware Workstation8.0.3 由于使用Ubuntu的人比较少,网上关于Ubuntu的资料也很少,笔者在安装VMware Wo ...
- linux shell 脚本攻略学习1
1.关于echo和printf打印输出 如果要使用转义序列,那么需要在echo 后面加上参数 -e来进行识别,下面例子是进行对比: amosli@amosli-pc:~/learn$ echo -e ...
- unix环境高级编程 读书笔记
1.上班业余时间把书下载下来,第一章读完了,但是程序只能回家运行啦!Fighting!
- linux中DHCP服务配置文件/etc/dhcpd.conf详细说明
DHCP服务的配置 dhcpd.conf 是DHCP服务的配置文件,DHCP服务所有参数都是通过修改dhcpd.conf 文件来实现,安装后dhcpd.conf 是没有做任何配置的,将/usr/sha ...
- 老男孩linux实战培训初级班第三次课课前考试题
################################################################ 本文内容摘录于老男孩linux实战运维培训中心考试题 如有转载,请务必 ...
- ubuntu源列表(清华,阿里,官方,选一即可)
Ubuntu的源列表在/etc/apt/sources.list中,替换即可 #清华的源deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial m ...
- ubuntu(14.04) sphinx安装
http://portal.digitser.cn/article-179-1.html
- k8s官方安装版本
一.概述 官方安装链接:https://kubernetes.io/docs/getting-started-guides/kubeadm/ 之前使用是yum直接安装组件,现由kubeadm来自动安装 ...