Godspped
Godspped

Reputation: 743

ffmpeg undefined references on multiple functions

I am trying to compile an application that is using ffmpeg on Ubuntu and I am running into the following errors.

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'

The version of ffmpeg I have:

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

In my makefile I have added -lavutil -lavcodec -lavdevice -lavfilter -lavformat -lswresample -lswscale to my link step.

What am I doing wrong? Are these deprecated in the version of ffmpeg I have?

Upvotes: 0

Views: 2432

Answers (2)

jetjetboi
jetjetboi

Reputation: 142

it could be due to your compiler unable to find the right place of the required components. if you know their whereabouts, you may try to use "symlink" to link it to the directory/place where your compiler is looking at.

eg:

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

Upvotes: 0

New Pagodi
New Pagodi

Reputation: 3554

The ffmpeg headers are pure C headers. So if you're trying to use them in a C++ application, you'll need to surround the include statement with the extern "C" declaration. For example:

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

If it's not clear what that declaration is doing, there are good explanations here and here.

Upvotes: 2

Related Questions