<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
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" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(74,107,130);text-decoration:none">https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu</a></p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">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 style="margin:0px 0px 10px;padding:10px 10px 1px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);quotes:none;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">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 style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">/tmp/ccKTprFq.o: In function `fetch_and_decode(int, int, bool)':</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">
ar2.cpp:(.text+0x36e): undefined reference to `avcodec_register_all'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">ar2.cpp:(.text+0x378): undefined reference to `av_log_set_level'</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">ar2.cpp:(.text+0x382): undefined reference to `avcodec_find_decoder'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">
ar2.cpp:(.text+0x3b1): undefined reference to `avcodec_alloc_context3'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">ar2.cpp:(.text+0x3d6): undefined reference to `avcodec_open2'</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">ar2.cpp:(.text+0x46d): undefined reference to `av_init_packet'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">
ar2.cpp:(.text+0x50a): undefined reference to `avcodec_decode_video2'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">ar2.cpp:(.text+0x534): undefined reference to `av_free_packet'</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">/tmp/ccKTprFq.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;clear:both">
collect2: error: ld returned 1 exit status</p></blockquote><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">
Just for a sane test if I remove the -L argument compiler says:</p><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">/usr/</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">bin</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">/</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">ld</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">:</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> cannot find </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">-</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">lavcodec</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">Which means that the linker finds the library in <em style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">/home/USER/ffmpeg_build/lib</em>. Also if we check the library for implementation it exists:</p>
<pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:18px">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">nm ffmpeg_build</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">/</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">lib</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">/</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">libavcodec</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">a </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">|</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> grep </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">"register_all"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent;color:rgb(128,0,0)">0000000000000000</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background-color:transparent"> T avcodec_register_all</span></code></pre>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">Also as advised since it is C++ I have <code style="margin:0px;padding:1px 5px;border:0px;vertical-align:baseline;background-color:rgb(238,238,238);font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:pre-wrap">exten "C"</code> around the include of the library.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:14px;vertical-align:baseline;clear:both;color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:18px">At this point I'm falling out of any ideas at all, why exactly compilation fails?</p>
</div>