gpt4 book ai didi

c++ - ffmpeg 对多个函数的 undefined reference

转载 作者:行者123 更新时间:2023-12-04 23:08:00 25 4
gpt4 key购买 nike

我正在尝试编译在 Ubuntu 上使用 ffmpeg 的应用程序,但遇到以下错误。

undefined reference to `av_write_image_line2'
undefined reference to `av_hwframe_transfer_data'
undefined reference to `av_hwdevice_get_hwframe_constraints'
undefined reference to `av_hwframe_get_buffer'
undefined reference to `av_hwdevice_ctx_create_derived'
undefined reference to `xcb_xfixes_get_cursor_image_cursor_image'
undefined reference to `xcb_xfixes_query_version'
undefined reference to `avpriv_slicethread_execute'
undefined reference to `avcodec_parameters_to_context'
undefined reference to `xcb_xfixes_get_cursor_image_reply'
undefined reference to `av_hwdevice_find_type_by_name'
undefined reference to `av_hwframe_map'
undefined reference to `av_spherical_tile_bounds'
undefined reference to `av_malloc_array'
undefined reference to `av_hwframe_transfer_get_formats'
undefined reference to `av_hwframe_ctx_alloc'
undefined reference to `xcb_shape_rectangles'
undefined reference to `av_stereo3d_type_name'
undefined reference to `avpriv_slicethread_free'
undefined reference to `avpriv_slicethread_create'
undefined reference to `xcb_xfixes_get_cursor_image'
undefined reference to `av_hwframe_ctx_init'
undefined reference to `avpriv_register_devices'
undefined reference to `av_hwframe_constraints_free'
undefined reference to `av_audio_fifo_peek_at'
undefined reference to `av_get_extended_channel_layout'
undefined reference to `av_hwframe_ctx_create_derived'
undefined reference to `xcb_xfixes_query_version_reply'
undefined reference to `av_mallocz_array'
undefined reference to `av_read_image_line2'

我拥有的 ffmpeg 版本:
ffmpeg version 4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.11) 20160609
configuration: --enable-pic --pkg-config-flags=--static --extra-libs='-lpthread -lm'
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100

在我的 makefile 中,我在链接步骤中添加了 -lavutil -lavcodec -lavdevice -lavfilter -lavformat -lswresample -lswscale。

我究竟做错了什么?这些在我拥有的 ffmpeg 版本中是否已弃用?

最佳答案

ffmpeg header 是纯 C header 。因此,如果您尝试在 C++ 应用程序中使用它们,您需要在 include 语句中加上 extern "C"。宣言。例如:

extern "C"
{
#include <libavcodec/avcodec.h>
}

如果不清楚该声明在做什么,有很好的解释 herehere .

关于c++ - ffmpeg 对多个函数的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55963016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com