title: Cmake error with ffmpeg and PkgConfig: cannot find -lpkgcfg_lib_LIBAV_stdc++
body: <p>I want to create my C++ project using ffmpeg and cmake on Ubuntu 18.04, but comes up with errors:</p>
  <pre><code>-- The C compiler identification is GNU 7.5.0
  -- The CXX compiler identification is GNU 7.5.0
  -- Check for working C compiler: /usr/bin/cc
  -- Check for working C compiler: /usr/bin/cc -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: /usr/bin/c++
  -- Check for working CXX compiler: /usr/bin/c++ -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PkgConfig: /usr/bin/pkg-config (found version &quot;0.29.1&quot;) 
  -- Checking for modules 'libavdevice;libavfilter;libavformat;libavcodec;libswresample;libswscale;libavutil'
  --   Found libavdevice, version 59.0.100
  --   Found libavfilter, version 8.1.103
  --   Found libavformat, version 59.4.101
  --   Found libavcodec, version 59.4.101
  --   Found libswresample, version 4.0.100
  --   Found libswscale, version 6.0.100
  --   Found libavutil, version 57.3.100
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/yg/Documents/xsplay/build
  Scanning dependencies of target xsplay
  [ 50%] Building CXX object CMakeFiles/xsplay.dir/src/ffplay.cpp.o
  [100%] Linking CXX executable xsplay
  /usr/bin/ld: cannot find -lpkgcfg_lib_LIBAV_stdc++-NOTFOUND
  /usr/bin/ld: cannot find -lpkgcfg_lib_LIBAV_gcc_s-NOTFOUND
  /usr/bin/ld: cannot find -lpkgcfg_lib_LIBAV_gcc-NOTFOUND
  collect2: error: ld returned 1 exit status
  CMakeFiles/xsplay.dir/build.make:233: recipe for target 'xsplay' failed
  make[2]: *** [xsplay] Error 1
  CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/xsplay.dir/all' failed
  make[1]: *** [CMakeFiles/xsplay.dir/all] Error 2
  Makefile:83: recipe for target 'all' failed
  make: *** [all] Error 2
  </code></pre>
  <p>FFmpeg version is 4.4, built from source code.</p>
  <pre><code>PATH=&quot;$HOME/bin:$PATH&quot; PKG_CONFIG_PATH=&quot;$HOME/ffmpeg_build/lib/pkgconfig&quot; ./configure \
    --prefix=&quot;$HOME/ffmpeg_build&quot; \
    --pkg-config-flags=&quot;--static&quot; \
    --extra-cflags=&quot;-I$HOME/ffmpeg_build/include&quot; \
    --extra-ldflags=&quot;-L$HOME/ffmpeg_build/lib&quot; \
    --extra-libs=&quot;-lpthread&quot; \
    --cxx=&quot;g++&quot; \
    --ld=&quot;g++&quot; \
    --bindir=&quot;$HOME/bin&quot; \
    --disable-ffplay \
    --enable-gpl \
    --enable-gnutls \
    --enable-libaom \
    --enable-libass \
    --enable-libfdk-aac \
    --enable-libfreetype \
    --enable-libmp3lame \
    --enable-libopus \
    --enable-libvorbis \
    --enable-libvpx \
    --enable-libx264 \
    --enable-libx265 \
    --enable-nonfree &amp;&amp; \
  PATH=&quot;$HOME/bin:$PATH&quot; make &amp;&amp; \
  make install &amp;&amp; \
  hash -r
  </code></pre>
  <p>I removed unnecessary code to simplify the project, below is main.cpp</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  extern &quot;C&quot;
  {
  #include &lt;libavutil/frame.h&gt;
  #include &lt;libavutil/mem.h&gt;
  #include &lt;libavcodec/avcodec.h&gt;
  }
  
  int main(int argc, char **argv)
  {
      printf(&quot;xsplay\n&quot;);
      return 0;
  }
  </code></pre>
  <p>CMakeLists.txt is modified from <a href="https://stackoverflow.com/a/61427931/8609327">https://stackoverflow.com/a/61427931/8609327</a>, I only changed cmake version to 3.10.</p>
  <pre><code>cmake_minimum_required(VERSION 3.10)
  
  project(xsplay)
  
  find_package(PkgConfig REQUIRED)
  pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
      libavdevice
      libavfilter
      libavformat
      libavcodec
      libswresample
      libswscale
      libavutil
  )
  
  add_executable(${PROJECT_NAME}
      main.cpp
  )
  
  target_link_libraries(${PROJECT_NAME}
      PkgConfig::LIBAV
  )
  </code></pre>
  <p>Please help me solve the problem, thanks!</p>