[FFmpeg-user] 'Undefined reference'-error when compiling FFMpeg
Tom Evans
tevans.uk at googlemail.com
Fri Mar 16 20:01:54 CET 2012
On Thu, Mar 15, 2012 at 6:54 PM, Anders Branderud
<anders.branderud at gmail.com> wrote:
> Hello!
>
> Here follows a problem that I would need your help with:
> I have installed the latest FFMpeg-library. I have tried to link to the
> library using two different Ubuntu-installations without any success.
>
> When I run the command
> 'ubuntu at ubuntu:/media/6982d030-e492-4bc9-a1e4-b674ef78cff0/home/david/Programs$
> sudo g++ -Iffmpeg/ -L/usr/lib videofecencoder.cc
> /media/6982d030-e492-4bc9-a1e4-b674ef78cff0/home/david/Programs/ffmpeg/libavformat/libavformat.a
> libavformat.so.53 -pthread', I get this error:
> ubuntu at ubuntu:/media/6982d030-e492-4bc9-a1e4-b674ef78cff0/home/david/Programs$
> sudo g++ -Iffmpeg/ -L/usr/lib videofecencoder.cc
> /media/6982d030-e492-4bc9-a1e4-b674ef78cff0/home/david/Programs/ffmpeg/libavformat/libavformat.a
> /media/6982d030-e492-4bc9-a1e4-b674ef78cff0/home/david/Programs/ffmpeg/libavutil/libavutil.a
> libavformat.so.53 -pthread
> /tmp/ccpX60ph.o: In function `video_encode_example(char const*, int)':
> videofecencoder.cc:(.text+0x30): undefined reference to
> `avcodec_find_encoder(CodecID)'
ld isn't prescient, it expects you to give it the libraries to link
against in the right order, or to tell it to loop through the
libraries specified to resolve the symbols (much slower).
The right order is the one where the required symbols are loaded
before they are referred to, so:
g++ -c -o videofecencoder.o videofecencoder.cc
g++ -o videofecencoder -L/foo/bar -lfoo -lbar videofecencoder.o
If you are still getting errors, use nm to examine the libraries you
are linking in and ensure they do have the symbols it is expecting.
Cheers
Tom
More information about the ffmpeg-user
mailing list