<div dir="ltr">I would like to simplify in order to add more libs to the ffmpeg like opencl and sdl libs and I do not know how to link using <span style="font-size:12.8px">pkg-config combined with no </span><span style="font-size:12.8px">pkg-config libraries</span><div><span style="font-size:12.8px">I tried to add the sdl-config but it did not worked.</span></div><div><span style="font-size:12.8px">I will try to add all those libraries and to list them using </span><span style="font-size:12.8px">pkg-config --libs, <br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">javier</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-29 14:29 GMT+02:00 Perette Barella <span dir="ltr"><<a href="mailto:perette@barella.org" target="_blank">perette@barella.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> Then I can compile and link using the following command line:<br>
> gcc  -o ffmpeg_grabber ffmpeg_grabber_03.c -Wall -ggdb $(pkg-config --cflags libavformat libavcodec libswresample libswscale libavutil sdl) $(pkg-config --libs libavformat libavcodec libswresample libswscale libavutil sdl) -lm<br>
><br>
> But I have a lot of link errors (undefined a lot of things) removing pkg-config:<br>
> gcc  -o test test.c -Wall -lavformat -lavcodec -lswresample -lswscale -lavutil -lm<br>
><br>
</span><span class="">> The question is: How to avoid undefine errors without using the pkg-config?<br>
<br>
</span>When static linking, you need to link not only the ffmpeg libraries themselves, but all the libraries that they link to in turn.  In this command:<br>
<span class="">> pkg-config --libs libavformat libavcodec libswresample libswscale libavutil sdl<br>
<br>
<br>
</span>`pkg-config --libs` gets the link flags necessary (there’s also a --cflags option too), including all those indirectly needed libraries, to link.  You can run pkg-config --libs on the command line to see the list.<br>
<br>
This list will not always be the same.  My Mac, for example, includes pthreads among the automatically-linked system libraries, so there will be no ‘-lpthreads’, but it includes -L/opt/local/lib, because it’s installed in a non-default place where the linker won’t look.  Link flags also depend on what ffmpeg was configured and built with: for example, if libfoobar is installed, there could be a dependency for -lfoobar; but if missing when I ran ./configure on ffmpeg, then I might have ffmpeg but without whatever capabilities foobar provides.  `configure` scripts see what’s available and build what they can, and they often utilize information from pkg-config where it’s available.<br>
<br>
I wonder *why* are you avoiding pkg-config? Are you planning to build/compile on a system without it?  Are you thinking of a portable `configure` script, and considering what to do if pkg-config is missing?  Because pkg-config came about to solve the problem you’re running into.  I’ve seen some debate about whether pkg-config solves the problem right, but it is the thing in place and trying to avoid it is to make yourself problems.  Not using it means a lot of extra trouble, so unless you have a *really* good reason...<br>
<span class="HOEnZb"><font color="#888888"><br>
Perette<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/<wbr>listinfo/libav-user</a><br>
</div></div></blockquote></div><br></div>