当前位置: 首页 > news >正文

ffmpeg编译问题

利用ffmpeg实现一个播放器,ffmpeg提供动态库,但是编译链接的时候遇到下面的问题:

../ffmpegWidgetPlayer/videoplayerwidget.cpp:23: error: undefined reference to 'sws_freeContext(SwsContext*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:28: error: undefined reference to 'av_frame_free(AVFrame**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:33: error: undefined reference to 'av_frame_free(AVFrame**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:38: error: undefined reference to 'avcodec_close(AVCodecContext*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:39: error: undefined reference to 'avcodec_free_context(AVCodecContext**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:44: error: undefined reference to 'avformat_close_input(AVFormatContext**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:55: error: undefined reference to 'avformat_network_init()'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:58: error: undefined reference to 'avformat_open_input(AVFormatContext**, char const*, AVInputFormat const*, AVDictionary**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:64: error: undefined reference to 'avformat_find_stream_info(AVFormatContext*, AVDictionary**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:84: error: undefined reference to 'avcodec_find_decoder(AVCodecID)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:91: error: undefined reference to 'avcodec_alloc_context3(AVCodec const*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:98: error: undefined reference to 'avcodec_parameters_to_context(AVCodecContext*, AVCodecParameters const*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:104: error: undefined reference to 'avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:110: error: undefined reference to 'av_frame_alloc()'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:117: error: undefined reference to 'av_frame_alloc()'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:124: error: undefined reference to 'av_image_get_buffer_size(AVPixelFormat, int, int, int)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:125: error: undefined reference to 'av_malloc(unsigned long)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:128: error: undefined reference to 'av_image_fill_arrays(unsigned char**, int*, unsigned char const*, AVPixelFormat, int, int, int)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:131: error: undefined reference to 'sws_getContext(int, int, AVPixelFormat, int, int, AVPixelFormat, int, SwsFilter*, SwsFilter*, double const*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:148: error: undefined reference to 'av_read_frame(AVFormatContext*, AVPacket*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:151: error: undefined reference to 'avcodec_send_packet(AVCodecContext*, AVPacket const*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:157: error: undefined reference to 'avcodec_receive_frame(AVCodecContext*, AVFrame*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:164: error: undefined reference to 'sws_scale(SwsContext*, unsigned char const* const*, int const*, int, int, unsigned char* const*, int const*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:170: error: undefined reference to 'av_frame_unref(AVFrame*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:174: error: undefined reference to 'av_packet_unref(AVPacket*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:187: error: undefined reference to 'sws_freeContext(SwsContext*)'
../ffmpegWidgetPlayer/videoplayerwidget.cpp:188: error: undefined reference to 'sws_getContext(int, int, AVPixelFormat, int, int, AVPixelFormat, int, SwsFilter*, SwsFilter*, double const*)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:288: ffmpegWidgetPlayer] Error 1
10:29:50: 进程"/usr/bin/make"退出,退出代码 2 。
Error while building/deploying project ffmpegWidgetPlayer (kit: Desktop Qt 5.15.2 GCC 64bit)
When executing step "Make"
10:29:50: Elapsed time: 00:03.

 通过分析报错信息可以看到在链接阶段提示ffmpeg相关的api找不到符号,看到这个问题百思不得其解,该工程我是利用qt编译链接,可以肯定的是pro文件中已经通过LIBS关键字指明了依赖库的路径和依赖库的名称,但是仍然提示找不到,最后通过查阅资料,才了解问题产生的原因:qt工程是c++代码,ffmpeg是c原因编写的,当c++代码调用C库时对c++代码中调用的头文件需要使用extern "C"包含起来,以此让编译器按照C的方式编译ffmpeg相关的头文件

解决方法如下:

#include <QWidget>
#include <QImage>
#include <QTimer>
#include <QPainter>
#include <QCoreApplication>
#include <QResizeEvent>
extern "C"   //按照C语言方式编译api接口
{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libswscale/swscale.h>
#include <libavutil/avutil.h>
#include <libpostproc/postprocess.h>
#include <libavutil/ffversion.h>
#include <libavutil/imgutils.h>
}

总结

下面对编译阶段“undefined reference to”的报错原因进行总结,希望能够大家有所帮助:

  • 产生这个报错简单的是就是依赖库未包含,就是说未指定依赖库的路径和和依赖库名称,这个通过LIBS关键字就可以解决
  • 如果确定LIBS等类似的方式已经指明依赖库的路径和依赖库名称,还是有这个报错,那么确认下是否是C++代码调用了C语言的库,如果属实,那么就是用extern "C"关键字包含C库的头文件

相关文章:

ffmpeg编译问题

利用ffmpeg实现一个播放器&#xff0c;ffmpeg提供动态库&#xff0c;但是编译链接的时候遇到下面的问题&#xff1a; ../ffmpegWidgetPlayer/videoplayerwidget.cpp:23: error: undefined reference to sws_freeContext(SwsContext*) ../ffmpegWidgetPlayer/videoplayerwidget.…...

【flink番外篇】1、flink的23种常用算子介绍及详细示例(3)-window、distinct、join等

Flink 系列文章 一、Flink 专栏 Flink 专栏系统介绍某一知识点&#xff0c;并辅以具体的示例进行说明。 1、Flink 部署系列 本部分介绍Flink的部署、配置相关基础内容。 2、Flink基础系列 本部分介绍Flink 的基础部分&#xff0c;比如术语、架构、编程模型、编程指南、基本的…...

centos7做gitlab数据灾备项目地址指向问题

如果你在 CentOS 7 上使用 GitLab 时&#xff0c;它回复的数据指向了另一个服务器的地址&#xff0c;可能是因为配置文件中的一些设置不正确。 要解决这个问题&#xff0c;可以尝试以下几个步骤&#xff1a; 检查 GitLab 配置文件&#xff1a;打开 GitLab 的配置文件&#xf…...

leetcode:93. 复原 IP 地址

复原 IP 地址 中等 1.4K 相关企业 有效 IP 地址 正好由四个整数&#xff08;每个整数位于 0 到 255 之间组成&#xff0c;且不能含有前导 0&#xff09;&#xff0c;整数之间用 ‘.’ 分隔。 例如&#xff1a;“0.1.2.201” 和 “192.168.1.1” 是 有效 IP 地址&#xff0c;但…...

玄子Share-CSS3 弹性布局知识手册

玄子Share-CSS3 弹性布局知识手册 Flexbox Layout&#xff08;弹性盒布局&#xff09;是一种在 CSS 中用于设计复杂布局结构的模型。它提供了更加高效、简便的方式来对容器内的子元素进行排列、对齐和分布 主轴和交叉轴 使用弹性布局&#xff0c;最重要的一个概念就是主轴与…...

Nat easy IP ACL

0表示匹配&#xff0c;1表示任意&#xff08;主机位0.0.0.255&#xff08;255主机位&#xff09;&#xff09; rule deny source 192.168.2.1 0 设置拒绝192.168.2.1的主机通过 记住将其应用到接口上 [AR2]acl 2000 //创建基本ACL [AR2-acl-basic-2000]rule deny source 192…...

Numpy数组的数据类型汇总 (第4讲)

Numpy数组的数据类型 (第4讲)         🍹博主 侯小啾 感谢您的支持与信赖。☀️ 🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ🌹꧔ꦿ�…...

通讯app:

为了开发一个即时通讯的app&#xff0c;包含发送文字、语音、视频以及视频通话的功能&#xff0c;我们需要考虑以下的技术栈和实现步骤&#xff1a; 技术栈建议&#xff1a; 前端&#xff1a;React Native 或 Flutter 用于跨平台移动应用开发。后端&#xff1a;ThinkPHP Wor…...

【Backbone】TransNeXt:最新ViT模型(原理+常用神经网络汇总)

文章目录 一、近几年神经网络 Backbone 回顾1.Densenet 与 Resnet2.CBP3.SENet4.GCNet5.DANet6.PANet 与 FPN7.ASPP8.SPP-net9.PSP-net10.ECA-Net 二、TransNeXt&#xff08;2023&#xff09;1.提出问题2.Aggregated Pixel-focused Attention2.1 Pixel-focused Attention&#…...

使用Java将图片添加到Excel的几种方式

1、超链接 使用POI&#xff0c;依赖如下 <dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>4.1.2</version></dependency>Java代码如下,运行该程序它会在桌面创建ImageLinks.xlsx文件。 …...

用什么台灯对眼睛最好?考公护眼台灯推荐

之前我一直觉得&#xff0c;孩子近视&#xff0c;是因为玩手机太多&#xff0c;看电子产品的时间过长&#xff0c;但后来控制孩子看电子产品时间的触底反弹与越来越深的度数告诉我&#xff0c;孩子近视的真正原因&#xff0c;我根本没有找到&#xff0c;后来看到一篇报告&#…...

【嵌入式开发 Linux 常用命令系列 4.2 -- .repo 各个目录介绍】

文章目录 概述.repo 目录结构manifests/default.xmlManifest 文件的作用default.xml 文件内容示例linkfile 介绍 .repo/projects 子目录配置和管理configHEADhooksinfo/excludeobjectsrr-cache 工作区中的对应目录 概述 repo 是一个由 Google 开发的版本控制工具&#xff0c;它…...

【C++学习手札】基于红黑树封装模拟实现map和set

​ &#x1f3ac;慕斯主页&#xff1a;修仙—别有洞天 &#x1f49c;本文前置知识&#xff1a; 红黑树 ♈️今日夜电波&#xff1a;漂流—菅原纱由理 2:55━━━━━━️&#x1f49f;──────── 4:29 …...

linux查看当前路径的所有文件大小;linux查看当前文件夹属于什么文件系统

1&#xff1a;指令查看当前路径所有文件内存空间大小&#xff1b;这样可以方便查询每个文件大小情况&#xff0c;根据需要进行删除 df -h // 根目录 du -ah --max-depth1 // 一级目录 虚拟机 du -ah -d 1 // 一级目录 设备使用 du -ah --max-depth2 // 二…...

PPT插件-好用的插件-超级文本-大珩助手

常用字体 内置了大量的常用字体&#xff0c;方便快捷的一键更换字体&#xff0c;避免系统字体过多卡顿 文字整理 包含删空白行、清理编号、清理格式&#xff0c;便于处理从网络上复制的资料 文本打散与合并 包含文本打散、文本合并&#xff0c;文本打散可实现将一个文本打散…...

Kafka中的Topic

在Kafka中&#xff0c;Topic是消息的逻辑容器&#xff0c;用于组织和分类消息。本文将深入探讨Kafka Topic的各个方面&#xff0c;包括创建、配置、生产者和消费者&#xff0c;以及一些实际应用中的示例代码。 1. 介绍 在Kafka中&#xff0c;Topic是消息的逻辑通道&#xff0…...

LAMP部署

目录 一、安装apache 二、配置mysql 三、安装php 四、搭建论坛 4、安装另一个网站 一、安装apache 1.关闭防火墙&#xff0c;将安装Apache所需软件包传到/opt目录下 systemctl stop firewalld systemctl disable firewalld setenforce 0 httpd-2.4.29.tar.gz apr-1.6.2.t…...

DouyinAPI接口开发系列丨商品详情数据丨视频详情数据

电商API就是各大电商平台提供给开发者访问平台数据的接口。目前&#xff0c;主流电商平台如淘宝、天猫、京东、苏宁等都有自己的API。 二、电商API的应用价值 1.直接对接原始数据源&#xff0c;数据提取更加准确和完整。 2.查询速度更快&#xff0c;可以快速响应用户请求实现…...

AWS Remote Control ( Wi-Fi ) on i.MX RT1060 EVK - 3 “编译 NXP i.MX RT1060”( 完 )

此章节叙述如何修改、建构 i.MX RT1060 的 Sample Code“aws_remote_control_wifi_nxp” 1. 点击“Import SDK example(s)” 2. 选择“MIMXRT1062xxxxA”>“evkmimxrt1060”&#xff0c;并确认 SDK 版本后&#xff0c;点击“Next>” 3. 选择“aws_examples”>“aw…...

5G - NR物理层解决方案支持6G非地面网络中的高移动性

文章目录 非地面网络场景链路仿真参数实验仿真结果 非地面网络场景 链路仿真参数 实验仿真结果 Figure 5 && Figure 6&#xff1a;不同信噪比下的BER和吞吐量 变量 SISO 2x2MIMO 2x4MIMO 2x8MIMOReyleigh衰落、Rician衰落、多径TDL-A(NLOS) 、TDL-E(LOS)(a)QPSK (b)16…...

Python|GIF 解析与构建(5):手搓截屏和帧率控制

目录 Python&#xff5c;GIF 解析与构建&#xff08;5&#xff09;&#xff1a;手搓截屏和帧率控制 一、引言 二、技术实现&#xff1a;手搓截屏模块 2.1 核心原理 2.2 代码解析&#xff1a;ScreenshotData类 2.2.1 截图函数&#xff1a;capture_screen 三、技术实现&…...

日语AI面试高效通关秘籍:专业解读与青柚面试智能助攻

在如今就业市场竞争日益激烈的背景下&#xff0c;越来越多的求职者将目光投向了日本及中日双语岗位。但是&#xff0c;一场日语面试往往让许多人感到步履维艰。你是否也曾因为面试官抛出的“刁钻问题”而心生畏惧&#xff1f;面对生疏的日语交流环境&#xff0c;即便提前恶补了…...

golang循环变量捕获问题​​

在 Go 语言中&#xff0c;当在循环中启动协程&#xff08;goroutine&#xff09;时&#xff0c;如果在协程闭包中直接引用循环变量&#xff0c;可能会遇到一个常见的陷阱 - ​​循环变量捕获问题​​。让我详细解释一下&#xff1a; 问题背景 看这个代码片段&#xff1a; fo…...

Oracle查询表空间大小

1 查询数据库中所有的表空间以及表空间所占空间的大小 SELECTtablespace_name,sum( bytes ) / 1024 / 1024 FROMdba_data_files GROUP BYtablespace_name; 2 Oracle查询表空间大小及每个表所占空间的大小 SELECTtablespace_name,file_id,file_name,round( bytes / ( 1024 …...

聊聊 Pulsar:Producer 源码解析

一、前言 Apache Pulsar 是一个企业级的开源分布式消息传递平台&#xff0c;以其高性能、可扩展性和存储计算分离架构在消息队列和流处理领域独树一帜。在 Pulsar 的核心架构中&#xff0c;Producer&#xff08;生产者&#xff09; 是连接客户端应用与消息队列的第一步。生产者…...

微服务商城-商品微服务

数据表 CREATE TABLE product (id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 商品id,cateid smallint(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT 类别Id,name varchar(100) NOT NULL DEFAULT COMMENT 商品名称,subtitle varchar(200) NOT NULL DEFAULT COMMENT 商…...

DBAPI如何优雅的获取单条数据

API如何优雅的获取单条数据 案例一 对于查询类API&#xff0c;查询的是单条数据&#xff0c;比如根据主键ID查询用户信息&#xff0c;sql如下&#xff1a; select id, name, age from user where id #{id}API默认返回的数据格式是多条的&#xff0c;如下&#xff1a; {&qu…...

C#中的CLR属性、依赖属性与附加属性

CLR属性的主要特征 封装性&#xff1a; 隐藏字段的实现细节 提供对字段的受控访问 访问控制&#xff1a; 可单独设置get/set访问器的可见性 可创建只读或只写属性 计算属性&#xff1a; 可以在getter中执行计算逻辑 不需要直接对应一个字段 验证逻辑&#xff1a; 可以…...

AirSim/Cosys-AirSim 游戏开发(四)外部固定位置监控相机

这个博客介绍了如何通过 settings.json 文件添加一个无人机外的 固定位置监控相机&#xff0c;因为在使用过程中发现 Airsim 对外部监控相机的描述模糊&#xff0c;而 Cosys-Airsim 在官方文档中没有提供外部监控相机设置&#xff0c;最后在源码示例中找到了&#xff0c;所以感…...

抽象类和接口(全)

一、抽象类 1.概念&#xff1a;如果⼀个类中没有包含⾜够的信息来描绘⼀个具体的对象&#xff0c;这样的类就是抽象类。 像是没有实际⼯作的⽅法,我们可以把它设计成⼀个抽象⽅法&#xff0c;包含抽象⽅法的类我们称为抽象类。 2.语法 在Java中&#xff0c;⼀个类如果被 abs…...