[Libav-user] segmentation fault on avcodec_decode_video2( ) call

Joshua Kordani jkordani at lsa2.com
Wed Mar 12 16:20:03 CET 2014

On 3/11/14 7:45 PM, Jason Blum wrote:
>> Once you do that and you get linker errors, paste those
>> to pastebin and link here I guess.
> The order of the linking makes a difference between the types of
> undefined reference errors that I'm getting.
> If I use:
> g++ -g -D__STDC_CONSTANT_MACROS -L/usr/local/lib/ -lswscale -lavformat
> -lavcodec main.cpp
> it results in the following: http://pastebin.com/LtJzA7Hj
> If I use:
> g++ main.cpp -g -D__STDC_CONSTANT_MACROS -L/usr/local/lib/ -lswscale
> -lavformat -lavcodec
> it results a 16000 line long error output too large for free PasteBin.
> The abridged version: http://pastebin.com/8dsv2pMY
> I don't really understand linking order issues, but I would have
> guessed at least one of the orders would have worked. If I don't
> include the -D__STDC_CONST_MACROS flag, one of the header files
> complains, so I think it is including the headers, which are in
> /usr/local/include.
> Any ideas what I'm missing?
Compile the main.cpp into an object file first, and then, link order 
should be main.o and then all the libraries.
I am not sure about the behavior of the compiler in this case and I 
think that it should "do the right thing", but to guarantee the proper 
linking order, build main into an object file, then link them all with 
main.o as the first in the list.

When linking, the linker maintains a master symbol table as it reads in 
objects and libraries.  Symbols from libraries are only included in the 
master symbol table if there have been prior references to them.  
Symbols from object files are included automatically.  main.o will 
reference everything needed from the libraries.  So a linker call with 
main.o followed by a pkg-config --libs ffmpeg (see below) should stand 
up the appropriate linker line.

Refer to doc/examples/Makefile. Here, simple example programs are built 
against ffmpeg libraries.  In this example, pkg-config is used to stand 
up the proper compiler and linker flags.  I'll admit, I don't know where 
in this makefile the actual compiler call is made, but notice how the 
makefile builds a list of object filenames.  In this makefile, 
pkg-config will find your systemwide installed .pc files, so if you wish 
to use locally built copy, .pc files are provided in a subdirectory of 
the installed location, and using pkg-config with an explicit path to 
these pc files "I believe" will let pkg-config stand up the args for 
your local ffmpeg libs.

Joshua Kordani
LSA Autonomy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20140312/91c24836/attachment.html>

More information about the Libav-user mailing list