[Libav-user] Can not link ffmpeg without pkg-config
jlopez2022 at gmail.com
Tue Aug 30 14:28:03 EEST 2016
I simplified a few using the pkg-config to one call by using both flags:
--clibs and --cflags:
gcc -o ffmpeg_player ffmpeg_player_01.c -Wall -ggdb $(pkg-config --cflags
--libs libavformat libavcodec libswresample libswscale libavutil sdl) -lm
And it worked!
I also tried to compile without the pkg-config adding all dependencies:
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
Still I have following error: libavcodec/libx264.c:814: undefined reference
I listed all dependencies of libavcodec and all of them where included,
perhaps order minds.
2016-08-29 16:11 GMT+02:00 Javier Lopez <jlopez2022 at gmail.com>:
> 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
>> > gcc -o test test.c -Wall -lavformat -lavcodec -lswresample -lswscale
>> -lavutil -lm
>> > The question is: How to avoid undefine errors without using the
>> 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
>> > 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...
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user