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

uniapp 对接腾讯云IM群组成员管理(增删改查)

UniApp 实战&#xff1a;腾讯云IM群组成员管理&#xff08;增删改查&#xff09; 一、前言 在社交类App开发中&#xff0c;群组成员管理是核心功能之一。本文将基于UniApp框架&#xff0c;结合腾讯云IM SDK&#xff0c;详细讲解如何实现群组成员的增删改查全流程。 权限校验…...

深入浅出Asp.Net Core MVC应用开发系列-AspNetCore中的日志记录

ASP.NET Core 是一个跨平台的开源框架&#xff0c;用于在 Windows、macOS 或 Linux 上生成基于云的新式 Web 应用。 ASP.NET Core 中的日志记录 .NET 通过 ILogger API 支持高性能结构化日志记录&#xff0c;以帮助监视应用程序行为和诊断问题。 可以通过配置不同的记录提供程…...

Golang 面试经典题:map 的 key 可以是什么类型?哪些不可以?

Golang 面试经典题&#xff1a;map 的 key 可以是什么类型&#xff1f;哪些不可以&#xff1f; 在 Golang 的面试中&#xff0c;map 类型的使用是一个常见的考点&#xff0c;其中对 key 类型的合法性 是一道常被提及的基础却很容易被忽视的问题。本文将带你深入理解 Golang 中…...

STM32+rt-thread判断是否联网

一、根据NETDEV_FLAG_INTERNET_UP位判断 static bool is_conncected(void) {struct netdev *dev RT_NULL;dev netdev_get_first_by_flags(NETDEV_FLAG_INTERNET_UP);if (dev RT_NULL){printf("wait netdev internet up...");return false;}else{printf("loc…...

Qt Widget类解析与代码注释

#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码&#xff0c;写上注释 当然可以&#xff01;这段代码是 Qt …...

高危文件识别的常用算法:原理、应用与企业场景

高危文件识别的常用算法&#xff1a;原理、应用与企业场景 高危文件识别旨在检测可能导致安全威胁的文件&#xff0c;如包含恶意代码、敏感数据或欺诈内容的文档&#xff0c;在企业协同办公环境中&#xff08;如Teams、Google Workspace&#xff09;尤为重要。结合大模型技术&…...

ElasticSearch搜索引擎之倒排索引及其底层算法

文章目录 一、搜索引擎1、什么是搜索引擎?2、搜索引擎的分类3、常用的搜索引擎4、搜索引擎的特点二、倒排索引1、简介2、为什么倒排索引不用B+树1.创建时间长,文件大。2.其次,树深,IO次数可怕。3.索引可能会失效。4.精准度差。三. 倒排索引四、算法1、Term Index的算法2、 …...

微信小程序云开发平台MySQL的连接方式

注&#xff1a;微信小程序云开发平台指的是腾讯云开发 先给结论&#xff1a;微信小程序云开发平台的MySQL&#xff0c;无法通过获取数据库连接信息的方式进行连接&#xff0c;连接只能通过云开发的SDK连接&#xff0c;具体要参考官方文档&#xff1a; 为什么&#xff1f; 因为…...

【Java学习笔记】BigInteger 和 BigDecimal 类

BigInteger 和 BigDecimal 类 二者共有的常见方法 方法功能add加subtract减multiply乘divide除 注意点&#xff1a;传参类型必须是类对象 一、BigInteger 1. 作用&#xff1a;适合保存比较大的整型数 2. 使用说明 创建BigInteger对象 传入字符串 3. 代码示例 import j…...

Python ROS2【机器人中间件框架】 简介

销量过万TEEIS德国护膝夏天用薄款 优惠券冠生园 百花蜂蜜428g 挤压瓶纯蜂蜜巨奇严选 鞋子除臭剂360ml 多芬身体磨砂膏280g健70%-75%酒精消毒棉片湿巾1418cm 80片/袋3袋大包清洁食品用消毒 优惠券AIMORNY52朵红玫瑰永生香皂花同城配送非鲜花七夕情人节生日礼物送女友 热卖妙洁棉…...