[Libav-user] Can not link ffmpeg without pkg-config

Javier Lopez jlopez2022 at gmail.com
Mon Aug 29 17:11:31 EEST 2016

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 pkg-config combined
with no pkg-config libraries
I tried to add the sdl-config but it did not worked.
I will try to add all those libraries and to list them using pkg-config


2016-08-29 14:29 GMT+02:00 Perette Barella <perette at barella.org>:

> > Then I can compile and link using the following command line:
> > 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
> >
> > But I have a lot of link errors (undefined a lot of things) removing
> pkg-config:
> > gcc  -o test test.c -Wall -lavformat -lavcodec -lswresample -lswscale
> -lavutil -lm
> >
> > The question is: How to avoid undefine errors without using the
> pkg-config?
> 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:
> > pkg-config --libs libavformat libavcodec libswresample libswscale
> libavutil sdl
> `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.
> 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.
> 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...
> Perette
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160829/54933c47/attachment.html>

More information about the Libav-user mailing list