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

usr/bin/ld链接报错undefined reference `av_frame_free(AVFrame**)‘等ffmpeg库报错

明明在CMakeLists.txt配置了ffmpeg库,还是链接一直报错:

usr/bin/ld: video_processor/libvideo_processor_lib.a(video_processor.cpp.o): in function `VideoProcessor::run()':
video_processor.cpp:(.text+0x17db): undefined reference to `av_frame_free(AVFrame**)'
/usr/bin/ld: video_processor.cpp:(.text+0x1842): undefined reference to `av_frame_free(AVFrame**)'
/usr/bin/ld: video_processor.cpp:(.text+0x1856): undefined reference to `av_frame_free(AVFrame**)'
/usr/bin/ld: ffmpeg_handler/libffmpeg_handler_lib.a(ffmpeg_handler.cpp.o): in function `FFmpegHandler::cleanupReader()':
ffmpeg_handler.cpp:(.text+0x1b5): undefined reference to `avcodec_free_context(AVCodecContext**)'
/usr/bin/ld: ffmpeg_handler.cpp:(.text+0x1d9): undefined reference to `avformat_close_input(AVFormatContext**)'
/usr/bin/ld: ffmpeg_handler.cpp:(.text+0x201): undefined reference to `av_frame_free(AVFrame**)'
/usr/bin/ld: ffmpeg_handler.cpp:(.text+0x22a): undefined reference to `av_packet_free(AVPacket**)'

最可能的原因是库的链接顺序错误,按avformat → avcodec → swscale → avutil的顺序重新配置后,再检查头文件包含和函数调用参数,即可解决链接错误。

ffmpeg.cpp不能配置

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavcodec/packet.h>
#include <libswscale/swscale.h>
#include <libavutil/opt.h>
#include <libavutil/frame.h> 
#include <libavutil/imgutils.h>
}

只能放在ffmpeg.h中

http://www.xdnf.cn/news/16987.html

相关文章:

  • VAE学习笔记
  • Visual Studio Code的下载,安装
  • 机器学习(11):岭回归Ridge
  • iOS混淆工具有哪些?功能测试与质量保障兼顾的混淆策略
  • OpenLayers 入门指南【五】:Map 容器
  • C语言的数组与字符串
  • 力扣热题100——双指针
  • Hadoop MapReduce 3.3.4 讲解~
  • SpringBoot自动装配原理
  • 36.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--缓存Token
  • 编程算法:技术创新与业务增长的核心驱动力
  • IDA9.1使用技巧(安装、中文字符串显示、IDA MCP服务器详细部署和MCP API函数修改开发经验)
  • 电商直播流量爆发式增长,华为云分布式流量治理与算力调度服务的应用场景剖析
  • 构建属于自己的第一个 MCP 服务器:初学者教程
  • 从零认识OpenFlow
  • 学习游戏制作记录(角色属性和状态脚本)8.4
  • 【Linux指南】软件安装全解析:从源码到包管理器的进阶之路
  • AI鉴伪技术鉴赏:“看不见”的伪造痕迹如何被AI识破
  • Java项目:基于SSM框架实现的电子病历管理系统【ssm+B/S架构+源码+数据库+毕业论文+远程部署】
  • Git如何同步本地与远程仓库并解决冲突
  • 【iOS】渲染原理离屏渲染
  • 打造个人数字图书馆:LeaNote+cpolar如何成为你的私有化知识中枢?
  • 时序数据库如何高效处理海量数据
  • Spring P1 | 创建你的第一个Spring MVC项目(IDEA图文详解版,社区版专业版都有~)
  • 【数据库】使用Sql Server创建索引优化查询速度,一般2万多数据后,通过非索引时间字段排序查询出现超时情况
  • Anthropic 禁止 OpenAI 访问 Claude API:商业竞争与行业规范的冲突
  • 接口重试方案,使用网络工具的内置重试机制,并发框架异步重试,Spring Retry,消息队列重试,Feign调用重试,监控与报警,避坑指南
  • Linux 系统启动原理
  • mac 技巧
  • Postman 四种请求体格式全解析:区别、用法及 Spring Boot 接收指南