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: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
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:
gcc -I/home/USER/ffmpeg_build/include -L/home/USER/ffmpeg_build/lib -lavcodec -o test.exe Downloads/auv/src/dronerosvideo/src/ar2.cpp
/tmp/ccKTprFq.o: In function `fetch_and_decode(int, int, bool)':
ar2.cpp:(.text+0x36e): undefined reference to `avcodec_register_all'
ar2.cpp:(.text+0x378): undefined reference to `av_log_set_level'
ar2.cpp:(.text+0x382): undefined reference to `avcodec_find_decoder'
ar2.cpp:(.text+0x3b1): undefined reference to `avcodec_alloc_context3'
ar2.cpp:(.text+0x3d6): undefined reference to `avcodec_open2'
ar2.cpp:(.text+0x46d): undefined reference to `av_init_packet'
ar2.cpp:(.text+0x50a): undefined reference to `avcodec_decode_video2'
ar2.cpp:(.text+0x534): undefined reference to `av_free_packet'
/tmp/ccKTprFq.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
Just for a sane test if I remove the -L argument compiler says:
/usr/bin/ld: cannot find -lavcodec
Which means that the linker finds the library in /home/USER/ffmpeg_build/lib. Also if we check the library for implementation it exists:
nm ffmpeg_build/lib/libavcodec.a | grep "register_all"
0000000000000000 T avcodec_register_all
Also as advised since it is C++ I have exten "C" around the include of the library.
At this point I'm falling out of any ideas at all, why exactly compilation fails?
/usr/bin/ldis the linker. You probably meant : 'the linker finds the library in/home/USER/ffmpeg_build/lib'. - didierc