title: CMake configuration for ffmpeg in C++ project
body: <p>I have installed ffmpeg (version 4) with Homebrew and I am trying to use the various ffmpeg libraries in a C++ project, but I am getting multiple errors during linking. </p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "_av_free", referenced from:
        _main in main.cpp.o
    "_av_packet_alloc", referenced from:
        _main in main.cpp.o
    "_av_parser_init", referenced from:
  And so on ... 
  </code></pre>
  
  <p>I have included the libraries as follow </p>
  
  <pre><code>extern "C" {
      #include &lt;libavutil/frame.h&gt;
      #include &lt;libavutil/mem.h&gt;
      #include &lt;libavcodec/avcodec.h&gt;
  }
  </code></pre>
  
  <p>But still, this doesn't work. I think I might have missed something in my <code>CMakeLists.txt</code> file, which at the moment looks like that :</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.6)
  project(decode_encode)
  
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_FLAGS "-D__STDC_CONSTANT_MACROS")
  
  add_executable(decode_encode main.cpp)
  </code></pre>
  
  <p>I most likely need to specify additional linking flags, but is there is a better way to handle the linking part in a <code>CMakeLists.txt</code> file?</p>