title: FFMPEG: undefined reference to `avcodec_register_all' does not link
body: <p>So I have a very sample code for trying to decode a FFMPEG video stream.
  My problem is avcodec does not want to link, to do so I made a clean installation of Ubuntu 13.04. I have build ffmpeg from source following the guide here: <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu" rel="nofollow noreferrer">https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu</a></p>
  <p>I just want to compile my file. Note that my ubuntu does not have any implementations or header files for avcodec. The command line I use is:</p>
  <blockquote>
  <p>gcc -I/home/USER/ffmpeg_build/include -L/home/USER/ffmpeg_build/lib -lavcodec -o test.exe Downloads/auv/src/dronerosvideo/src/ar2.cpp</p>
  <p>/tmp/ccKTprFq.o: In function `fetch_and_decode(int, int, bool)':</p>
  <p>ar2.cpp:(.text+0x36e):
  undefined reference to `avcodec_register_all'</p>
  <p>ar2.cpp:(.text+0x378):
  undefined reference to `av_log_set_level'</p>
  <p>ar2.cpp:(.text+0x382):
  undefined reference to `avcodec_find_decoder'</p>
  <p>ar2.cpp:(.text+0x3b1):
  undefined reference to `avcodec_alloc_context3'</p>
  <p>ar2.cpp:(.text+0x3d6):
  undefined reference to `avcodec_open2'</p>
  <p>ar2.cpp:(.text+0x46d):
  undefined reference to `av_init_packet'</p>
  <p>ar2.cpp:(.text+0x50a):
  undefined reference to `avcodec_decode_video2'</p>
  <p>ar2.cpp:(.text+0x534):
  undefined reference to `av_free_packet'</p>
  <p>/tmp/ccKTprFq.o:(.eh_frame+0x13): undefined reference to
  `__gxx_personality_v0'</p>
  <p>collect2: error: ld returned 1 exit status</p>
  </blockquote>
  <p>Just for a sane test if I remove the -L argument compiler says:</p>
  <pre><code>/usr/bin/ld: cannot find -lavcodec
  </code></pre>
  <p>Which means that the linker finds the library in  <em>/home/USER/ffmpeg_build/lib</em>. Also if we check the library for implementation it exists:</p>
  <pre><code>nm ffmpeg_build/lib/libavcodec.a | grep &quot;register_all&quot;
  0000000000000000 T avcodec_register_all
  </code></pre>
  <p>Also as advised since it is C++ I have <code>exten &quot;C&quot;</code> around the include of the library.</p>
  <p>At this point I'm falling out of any ideas at all, why exactly compilation fails?</p>