当前位置: 首页 > 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…...

C++_核心编程_多态案例二-制作饮品

#include <iostream> #include <string> using namespace std;/*制作饮品的大致流程为&#xff1a;煮水 - 冲泡 - 倒入杯中 - 加入辅料 利用多态技术实现本案例&#xff0c;提供抽象制作饮品基类&#xff0c;提供子类制作咖啡和茶叶*//*基类*/ class AbstractDr…...

使用VSCode开发Django指南

使用VSCode开发Django指南 一、概述 Django 是一个高级 Python 框架&#xff0c;专为快速、安全和可扩展的 Web 开发而设计。Django 包含对 URL 路由、页面模板和数据处理的丰富支持。 本文将创建一个简单的 Django 应用&#xff0c;其中包含三个使用通用基本模板的页面。在此…...

Lombok 的 @Data 注解失效,未生成 getter/setter 方法引发的HTTP 406 错误

HTTP 状态码 406 (Not Acceptable) 和 500 (Internal Server Error) 是两类完全不同的错误&#xff0c;它们的含义、原因和解决方法都有显著区别。以下是详细对比&#xff1a; 1. HTTP 406 (Not Acceptable) 含义&#xff1a; 客户端请求的内容类型与服务器支持的内容类型不匹…...

AI Agent与Agentic AI:原理、应用、挑战与未来展望

文章目录 一、引言二、AI Agent与Agentic AI的兴起2.1 技术契机与生态成熟2.2 Agent的定义与特征2.3 Agent的发展历程 三、AI Agent的核心技术栈解密3.1 感知模块代码示例&#xff1a;使用Python和OpenCV进行图像识别 3.2 认知与决策模块代码示例&#xff1a;使用OpenAI GPT-3进…...

CentOS下的分布式内存计算Spark环境部署

一、Spark 核心架构与应用场景 1.1 分布式计算引擎的核心优势 Spark 是基于内存的分布式计算框架&#xff0c;相比 MapReduce 具有以下核心优势&#xff1a; 内存计算&#xff1a;数据可常驻内存&#xff0c;迭代计算性能提升 10-100 倍&#xff08;文档段落&#xff1a;3-79…...

Vue2 第一节_Vue2上手_插值表达式{{}}_访问数据和修改数据_Vue开发者工具

文章目录 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染2. 插值表达式{{}}3. 访问数据和修改数据4. vue响应式5. Vue开发者工具--方便调试 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染 准备容器引包创建Vue实例 new Vue()指定配置项 ->渲染数据 准备一个容器,例如: …...

Java多线程实现之Callable接口深度解析

Java多线程实现之Callable接口深度解析 一、Callable接口概述1.1 接口定义1.2 与Runnable接口的对比1.3 Future接口与FutureTask类 二、Callable接口的基本使用方法2.1 传统方式实现Callable接口2.2 使用Lambda表达式简化Callable实现2.3 使用FutureTask类执行Callable任务 三、…...

SpringBoot+uniapp 的 Champion 俱乐部微信小程序设计与实现,论文初版实现

摘要 本论文旨在设计并实现基于 SpringBoot 和 uniapp 的 Champion 俱乐部微信小程序&#xff0c;以满足俱乐部线上活动推广、会员管理、社交互动等需求。通过 SpringBoot 搭建后端服务&#xff0c;提供稳定高效的数据处理与业务逻辑支持&#xff1b;利用 uniapp 实现跨平台前…...

2025 后端自学UNIAPP【项目实战:旅游项目】6、我的收藏页面

代码框架视图 1、先添加一个获取收藏景点的列表请求 【在文件my_api.js文件中添加】 // 引入公共的请求封装 import http from ./my_http.js// 登录接口&#xff08;适配服务端返回 Token&#xff09; export const login async (code, avatar) > {const res await http…...

分布式增量爬虫实现方案

之前我们在讨论的是分布式爬虫如何实现增量爬取。增量爬虫的目标是只爬取新产生或发生变化的页面&#xff0c;避免重复抓取&#xff0c;以节省资源和时间。 在分布式环境下&#xff0c;增量爬虫的实现需要考虑多个爬虫节点之间的协调和去重。 另一种思路&#xff1a;将增量判…...