title: FFMPEG Link error
body: <p>I'm trying to compile a modified version of this <a href="https://www.ffmpeg.org/doxygen/2.3/transcoding_8c-example.html%60" rel="nofollow noreferrer">transcoding example from the FFMPEG site</a>, I've used all the required includes and joined the libs using this :</p>
  <pre><code>INCLUDEPATH += $$(FFMPEG_DEV_PATH)\include
      LIBS += -L$$(FFMPEG_DEV_PATH)\lib -lavformat -lavcodec -lavutil -lswscale -liconv -lz -lavfilter
  </code></pre>
  <p>but I get this linking error that I can't understand :</p>
  <pre><code>  &quot;avio_close(AVIOContext*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;av_strerror(int, char*, unsigned long)&quot;, referenced from:
        av_make_error_string(char*, unsigned long, int) in PhVideoEncoder.o
    &quot;av_rescale_q(long long, AVRational, AVRational)&quot;, referenced from:
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;av_frame_free(AVFrame**)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;av_read_frame(AVFormatContext*, AVPacket*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avcodec_close(AVCodecContext*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)&quot;, referenced from:
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;av_dump_format(AVFormatContext*, int, char const*, int)&quot;, referenced from:
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;av_frame_alloc()&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
    &quot;av_free_packet(AVPacket*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;av_init_packet(AVPacket*)&quot;, referenced from:
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;av_opt_set_bin(void*, char const*, unsigned char const*, int, int)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;av_register_all()&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;av_rescale_q_rnd(long long, AVRational, AVRational, AVRounding)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;av_write_trailer(AVFormatContext*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avfilter_graph_free(AVFilterGraph**)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avfilter_inout_free(AVFilterInOut**)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avformat_new_stream(AVFormatContext*, AVCodec const*)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)&quot;, referenced from:
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
    &quot;avcodec_copy_context(AVCodecContext*, AVCodecContext const*)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;avcodec_find_decoder(AVCodecID)&quot;, referenced from:
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
    &quot;avcodec_find_encoder(AVCodecID)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;avfilter_get_by_name(char const*)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avfilter_graph_alloc()&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avfilter_inout_alloc()&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avformat_close_input(AVFormatContext**)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avcodec_decode_audio4(AVCodecContext*, AVFrame*, int*, AVPacket const*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avcodec_decode_video2(AVCodecContext*, AVFrame*, int*, AVPacket const*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avcodec_encode_audio2(AVCodecContext*, AVPacket*, AVFrame const*, int*)&quot;, referenced from:
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;avcodec_encode_video2(AVCodecContext*, AVPacket*, AVFrame const*, int*)&quot;, referenced from:
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;avfilter_graph_config(AVFilterGraph*, void*)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avfilter_register_all()&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avformat_free_context(AVFormatContext*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;avformat_write_header(AVFormatContext*, AVDictionary**)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;av_get_sample_fmt_name(AVSampleFormat)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;av_buffersink_get_frame(AVFilterContext*, AVFrame*)&quot;, referenced from:
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
    &quot;avfilter_graph_parse_ptr(AVFilterGraph*, char const*, AVFilterInOut**, AVFilterInOut**, void*)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avformat_find_stream_info(AVFormatContext*, AVDictionary**)&quot;, referenced from:
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
    &quot;av_interleaved_write_frame(AVFormatContext*, AVPacket*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
    &quot;av_buffersrc_add_frame_flags(AVFilterContext*, AVFrame*, int)&quot;, referenced from:
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
    &quot;avfilter_graph_create_filter(AVFilterContext**, AVFilter const*, char const*, char const*, void*, AVFilterGraph*)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;av_get_default_channel_layout(int)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avformat_alloc_output_context2(AVFormatContext**, AVOutputFormat*, char const*, char const*)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;av_get_channel_layout_nb_channels(unsigned long long)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
    &quot;av_frame_get_best_effort_timestamp(AVFrame const*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;av_log(void*, int, char const*, ...)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
        PhVideoEncoder::flush_encoder(unsigned int) in PhVideoEncoder.o
        PhVideoEncoder::open_input_file(char const*) in PhVideoEncoder.o
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
        PhVideoEncoder::encode_write_frame(AVFrame*, unsigned int, int*) in PhVideoEncoder.o
        ...
    &quot;av_free(void*)&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;av_malloc(unsigned long)&quot;, referenced from:
        av_malloc_array(unsigned long, unsigned long) in PhVideoEncoder.o
    &quot;av_strdup(char const*)&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;avio_open(AVIOContext**, char const*, int)&quot;, referenced from:
        PhVideoEncoder::open_output_file(char const*) in PhVideoEncoder.o
  </code></pre>
  <p>I tried looking for missing libraries but with no luck... What am I missing ?</p>
  <h1>EDIT</h1>
  <p>Thanks to the first answer, I added the <code>extern C</code> stuff but I still face a few errors :</p>
  <pre><code>Undefined symbols for architecture x86_64:
    &quot;_av_buffersink_get_frame&quot;, referenced from:
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
    &quot;_av_buffersrc_add_frame_flags&quot;, referenced from:
        PhVideoEncoder::filter_encode_write_frame(AVFrame*, unsigned int) in PhVideoEncoder.o
    &quot;_avfilter_get_by_name&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_graph_alloc&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_graph_config&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_graph_create_filter&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_graph_free&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
    &quot;_avfilter_graph_parse_ptr&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_inout_alloc&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_inout_free&quot;, referenced from:
        PhVideoEncoder::init_filter(FilteringContext*, AVCodecContext*, AVCodecContext*, char const*) in PhVideoEncoder.o
    &quot;_avfilter_register_all&quot;, referenced from:
        PhVideoEncoder::PhVideoEncoder(QString) in PhVideoEncoder.o
  ld: symbol(s) not found for architecture x86_64
  </code></pre>