From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil
Date: Sun, 16 Sep 2018 22:22:24 +0200 [thread overview]
Message-ID: <20180916222224.519fa1f8@windsurf> (raw)
In-Reply-To: <20180911204230.15890-1-giulio.benetti@micronovasrl.com>
Hello Giulio,
On Tue, 11 Sep 2018 22:42:30 +0200, Giulio Benetti wrote:
> When static linking programs using ffmpeg libraries, if linking against
> libavutil, -ldrm is listed before -lavutil.
I think this is not relevant in the explanation, the fact that motion
links with libdrm directly is independent from the fact that ffmpeg may
use libdrm internally.
> This leads to linking failure
> due to undefined reference of drmGetVersion() and drmFreeVersion().
> This is why when pkg-config generates libavutil.pc doesn't append -ldrm
pkg-config does not generate .pc files, it only reads them.
> after -lavutil.
> Subsequentely if a package uses pkg-config and ffmpeg it will load
> library dependencies from libavutil.pc without placing -ldrm at the tail.
Well, the fact that it's at the tail is a detail, but the main problem
is that the libavutil.pc file does not list *at all* the dependency on
libdrm.
> Without this fix the only way is to workaround the problem directly in
> the single package, like this:
"the single package" is not very clear, I would say "in each package
using ffmpeg".
> https://github.com/buildroot/buildroot/commit/daf7dd87f4d93923df5e757fd43b3ad214a4a2ae
>
> Add patch to assure -ldrm comes after -lavutil when static linking.
No, that's not what the patch does. The patch ensures that libavutil.pc
tells pkg-config that linking against libdrm is needed.
> ++enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
> + enabled libfdk_aac && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
> + { require libfdk_aac fdk-aac/aacenc_lib.h aacEncOpen -lfdk-aac &&
> + warn "using libfdk without pkg-config"; } }
> +@@ -7096,7 +7096,7 @@ source_path=${source_path}
> + LIBPREF=${LIBPREF}
> + LIBSUF=${LIBSUF}
> +
> +-extralibs_avutil="$LIBRT $LIBM"
> ++extralibs_avutil="$LIBDRM $LIBRT $LIBM"
This fix is in fact not the most correct one. Indeed, it does the
following change to libavutil.pc:
-Libs: -L${libdir} -lavutil -lm
+Libs: -L${libdir} -lavutil -ldrm -lm
but the proper change would be:
Libs: -L${libdir} -lavutil -lm
-Libs.private:
+Libs.private: -ldrm
Indeed, when we're dynamic linking, there is no need to link consumers
of libavutil with libdrm. It is only when we're statically linking that
it should be done. And that's exactly what Libs vs. Libs.private is for.
Best regards,
Thomas Petazzoni
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2018-09-16 20:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-11 20:42 [Buildroot] [PATCH] ffmpeg: fix static linking build failure when using libavutil Giulio Benetti
2018-09-11 21:47 ` Giulio Benetti
2018-09-13 8:15 ` Giulio Benetti
2018-09-16 20:22 ` Thomas Petazzoni [this message]
2018-09-24 10:26 ` Giulio Benetti
2018-09-24 11:09 ` Thomas Petazzoni
2018-09-24 11:11 ` Giulio Benetti
2018-10-12 17:38 ` Giulio Benetti
2018-10-12 19:50 ` Thomas Petazzoni
2018-10-12 20:54 ` Giulio Benetti
2018-10-16 19:31 ` Giulio Benetti
2018-10-17 10:36 ` Giulio Benetti
2018-10-17 12:37 ` [Buildroot] [PATCH v2] " Giulio Benetti
2018-10-17 12:39 ` Giulio Benetti
2018-10-17 12:49 ` [Buildroot] [PATCH v3] " Giulio Benetti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180916222224.519fa1f8@windsurf \
--to=thomas.petazzoni@bootlin.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox