ffmpeg多个函数上的未定义引用

时间:2019-05-03 03:42:52

标签: c++ ffmpeg

我正在尝试在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版本中已弃用吗?

2 个答案:

答案 0 :(得分:1)

ffmpeg标头是纯C标头。因此,如果要在C ++应用程序中使用它们,则需要用DpiY声明包围include语句。例如:

extern "C"

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

答案 1 :(得分:0)

这可能是由于您的编译器无法找到所需组件的正确位置。如果知道他们的下落,则可以尝试使用“符号链接”将其链接到编译器正在查看的目录/位置。

例如:

在-s / path / of / the / library / path / you / want / it / to / be / found