<div dir="ltr"><div><div>I simplified a few using the pkg-config to one call by using both flags: --clibs and --cflags:<br><br>gcc  -o ffmpeg_player ffmpeg_player_01.c -Wall -ggdb $(pkg-config --cflags --libs libavformat libavcodec libswresample libswscale libavutil sdl) -lm<br><br></div>And it worked!<br><br><br></div>I also tried to compile without the pkg-config adding all dependencies:<br><div><div><br>gcc  -o ffmpeg_player ffmpeg_player_01.c -Wall -ggdb -lavformat -lvdpau -lva -lva-drm -lva-x11 -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lX11 -lasound -lSDL -lx264 -lmp3lame -lfdk-aac -lm -lz -pthread -lavcodec -lvdpau -lswresample -lswscale -lavutil -lSDL <br><br></div><div>Still I have following error: libavcodec/libx264.c:814: undefined reference to `x264_encoder_open_148'<br><br></div><div>I listed all dependencies of libavcodec and all of them where included, perhaps order minds.<br></div><div><br><br><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-29 16:11 GMT+02:00 Javier Lopez <span dir="ltr"><<a href="mailto:jlopez2022@gmail.com" target="_blank">jlopez2022@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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, <span class="HOEnZb"><font color="#888888"><br></font></span></span></div><span class="HOEnZb"><font color="#888888"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">javier</span></div></font></span></div><div class="HOEnZb"><div class="h5"><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>> 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>> 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>> 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><font color="#888888"><br>
Perette<br>
</font></span><div><div><br>
______________________________<wbr>_________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer" target="_blank">http://ffmpeg.org/mailman/list<wbr>info/libav-user</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>