[Libav-user] 'Undefined reference'-error when using functions of libavcodec, compiling in Linux

Anders Branderud anders.branderud at gmail.com
Fri Mar 16 13:36:35 CET 2012


Hello!

When I run the encoding example (code inserted to the following cc-file)
provided in doc/examples of the FFMpeg-library and compile it with the line
*linux-y8h9:/home/anders/Programs # g++ videofecencoder.cc -lavformat
-lavcodec -lavutil*
*
*
I get the following error message:
/tmp/ccDQpTY5.o: In function `video_encode_example(char const*, int)':
videofecencoder.cc:(.text+0x30): undefined reference to
`avcodec_find_encoder(CodecID)'
videofecencoder.cc:(.text+0x75): undefined reference to
`avcodec_alloc_context3(AVCodec*)'
videofecencoder.cc:(.text+0x7d): undefined reference to
`avcodec_alloc_frame()'
videofecencoder.cc:(.text+0xfc): undefined reference to `av_opt_set(void*,
char const*, char const*, int)'
videofecencoder.cc:(.text+0x116): undefined reference to
`avcodec_open2(AVCodecContext*, AVCodec*, AVDictionary**)'
videofecencoder.cc:(.text+0x1e2): undefined reference to
`av_image_alloc(unsigned char**, int*, int, int, PixelFormat, int)'
videofecencoder.cc:(.text+0x330): undefined reference to
`avcodec_encode_video(AVCodecContext*, unsigned char*, int, AVFrame const*)'
videofecencoder.cc:(.text+0x3b3): undefined reference to
`avcodec_encode_video(AVCodecContext*, unsigned char*, int, AVFrame const*)'
videofecencoder.cc:(.text+0x464): undefined reference to
`avcodec_close(AVCodecContext*)'
videofecencoder.cc:(.text+0x46f): undefined reference to `av_free(void*)'
videofecencoder.cc:(.text+0x47c): undefined reference to `av_free(void*)'
videofecencoder.cc:(.text+0x487): undefined reference to `av_free(void*)'
/tmp/ccDQpTY5.o: In function `main':
videofecencoder.cc:(.text+0x4a8): undefined reference to
`avcodec_register_all()'
collect2: ld returned 1 exit status

I have tried the same using two different Ubuntu-installations. The above
compilation was performed using OpenSUSE installed in a VirtualBox. I did
the above at a new installation of OpenSUSE. After installing it I
downloaded the required libraries using the libraries provided in the
Software repository called 'PackMan'.

How do I resolve this?
Thanks in advance!

-- *Kind regards, Anders Branderud*

[Personal blog] Will of the
Creator<http://www.proofexistencegod.com/will-of-god/will-of-god/>  :
Logical
reasons - based on scientific premises - for the existence of a Super
intelligent and Orderly Creator and that He hasn't left His sapient
creatures without an Instruction Manual - Torah ['books of Moses'] - to
ascertain, and aspire to, His purpose.

[Company] Anders Branderud IT Solutions - www.abitsolutions.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120316/e9bb6513/attachment.html>


More information about the Libav-user mailing list