[FFmpeg-devel] configure: add LIBDRM to extralibs_avutil

Submitted by Giulio Benetti on Sept. 11, 2018, 8:29 p.m.

Details

Message ID 20180911202932.14724-1-giulio.benetti@micronovasrl.com
State New
Headers show

Commit Message

Giulio Benetti Sept. 11, 2018, 8:29 p.m.
When static linking programs using ffmpeg libraries, if linking against
libavutil, -ldrm is listed before -lavutil. This leads to linking failure
due to undefined reference of drmGetVersion() and drmFreeVersion().
This is why when pkg-config create libavutil.pc doesn't append -ldrm
after -lavutil.

Create LIBDRM=-ldrm in case libdrm is enabled and add $LIBDRM to
extralibs_avutil.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
---
 configure | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

James Almer Sept. 11, 2018, 8:49 p.m.
On 9/11/2018 5:29 PM, Giulio Benetti wrote:
> When static linking programs using ffmpeg libraries, if linking against
> libavutil, -ldrm is listed before -lavutil. This leads to linking failure
> due to undefined reference of drmGetVersion() and drmFreeVersion().
> This is why when pkg-config create libavutil.pc doesn't append -ldrm
> after -lavutil.
> 
> Create LIBDRM=-ldrm in case libdrm is enabled and add $LIBDRM to
> extralibs_avutil.

I'm not sure i understand. libdrm is already added to avutil extralibs,
seeing it's listed in the "avutil_suggest" line in configure. I see it's
also added to avdevice if kmsgrab_indev is enabled.

The -ldrm ldflag, assuming the libdrm pkg-config file is correct, should
be in $avutil_extralibs when configure dumps it into extralibs_avutil
for the purpose of creating libavutil.pc.

> 
> Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
> ---
>  configure | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index ef97c6b500..28bc3481bc 100755
> --- a/configure
> +++ b/configure
> @@ -6057,7 +6057,7 @@ enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_
>  enabled libcodec2         && require libcodec2 codec2/codec2.h codec2_create -lcodec2
>  enabled libdavs2          && require_pkg_config libdavs2 "davs2 >= 1.5.115" davs2.h davs2_decoder_open
>  enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
> -enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
> +enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
>  enabled libfdk_aac        && { check_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"; } }
> @@ -7347,7 +7347,7 @@ rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}")
>  source_path=${source_path}
>  LIBPREF=${LIBPREF}
>  LIBSUF=${LIBSUF}
> -extralibs_avutil="$avutil_extralibs"
> +extralibs_avutil="$avutil_extralibs $LIBDRM"
>  extralibs_avcodec="$avcodec_extralibs"
>  extralibs_avformat="$avformat_extralibs"
>  extralibs_avdevice="$avdevice_extralibs"
>
Giulio Benetti Sept. 11, 2018, 8:59 p.m.
Hello,

Il 11/09/2018 22:49, James Almer ha scritto:
> On 9/11/2018 5:29 PM, Giulio Benetti wrote:
>> When static linking programs using ffmpeg libraries, if linking against
>> libavutil, -ldrm is listed before -lavutil. This leads to linking failure
>> due to undefined reference of drmGetVersion() and drmFreeVersion().
>> This is why when pkg-config create libavutil.pc doesn't append -ldrm
>> after -lavutil.
>>
>> Create LIBDRM=-ldrm in case libdrm is enabled and add $LIBDRM to
>> extralibs_avutil.
> 
> I'm not sure i understand. libdrm is already added to avutil extralibs,
> seeing it's listed in the "avutil_suggest" line in configure. I see it's
> also added to avdevice if kmsgrab_indev is enabled.
> 
> The -ldrm ldflag, assuming the libdrm pkg-config file is correct, should
> be in $avutil_extralibs when configure dumps it into extralibs_avutil
> for the purpose of creating libavutil.pc.
> 

I point you a build failure, so it should be more clear.
I did my best to explain on commit log, but it wasn't easy.

http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75/build-end.log

In that case .configure file is different but the point is the same.

At the end of the log you can see that -ldrm is yes present, but it 
comes too early respect to -lavutil.
This situation is valid only in the case you link *statically*.
For dynamic linking there's no problem at all.

Thanks and
Best regards
Giulio Benetti
James Almer Sept. 11, 2018, 9:21 p.m.
On 9/11/2018 5:59 PM, Giulio Benetti wrote:
> Hello,
> 
> Il 11/09/2018 22:49, James Almer ha scritto:
>> On 9/11/2018 5:29 PM, Giulio Benetti wrote:
>>> When static linking programs using ffmpeg libraries, if linking against
>>> libavutil, -ldrm is listed before -lavutil. This leads to linking
>>> failure
>>> due to undefined reference of drmGetVersion() and drmFreeVersion().
>>> This is why when pkg-config create libavutil.pc doesn't append -ldrm
>>> after -lavutil.
>>>
>>> Create LIBDRM=-ldrm in case libdrm is enabled and add $LIBDRM to
>>> extralibs_avutil.
>>
>> I'm not sure i understand. libdrm is already added to avutil extralibs,
>> seeing it's listed in the "avutil_suggest" line in configure. I see it's
>> also added to avdevice if kmsgrab_indev is enabled.
>>
>> The -ldrm ldflag, assuming the libdrm pkg-config file is correct, should
>> be in $avutil_extralibs when configure dumps it into extralibs_avutil
>> for the purpose of creating libavutil.pc.
>>
> 
> I point you a build failure, so it should be more clear.
> I did my best to explain on commit log, but it wasn't easy.
> 
> http://autobuild.buildroot.net/results/515/5152dcca58944cf732d09fba6e6c9af8a9243c75/build-end.log
> 
> 
> In that case .configure file is different but the point is the same.
> 
> At the end of the log you can see that -ldrm is yes present, but it
> comes too early respect to -lavutil.
> This situation is valid only in the case you link *statically*.
> For dynamic linking there's no problem at all.
> 
> Thanks and
> Best regards
> Giulio Benetti

> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz -pthread -latomic -lswresample  -lavutil -lm  

What i'm seeing here is that -ldrm is apparently present in
libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
that it's strictly listed in the avutil_suggest list.

What version of ffmpeg is this script using? Latest git head, an old
snapshot, or a release? Did this start failing recently?
This patch is a hacky way to add the "-ldrm" ldflag to avutil_extralibs.
It should be added organically by configure as part of the dependency
checks, so this is definitely not an adequate fix.
Giulio Benetti Sept. 11, 2018, 9:24 p.m.
Hello,

Il 11/09/2018 23:21, James Almer ha scritto:
>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz -pthread -latomic -lswresample  -lavutil -lm
> 
> What i'm seeing here is that -ldrm is apparently present in
> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
> that it's strictly listed in the avutil_suggest list.
> 
> What version of ffmpeg is this script using? Latest git head, an old
> snapshot, or a release? Did this start failing recently?

It happens on version 3.4.4 and I haven't foud fixes until master(maybe 
I've missed something, I'm quite new to this).

> This patch is a hacky way to add the "-ldrm" ldflag to avutil_extralibs.
> It should be added organically by configure as part of the dependency
> checks, so this is definitely not an adequate fix.

Can you point me the right way to fix this?
It was the only way I've found to have it working.

Thanks in advance
Giulio Benetti
Giulio Benetti Sept. 11, 2018, 9:34 p.m.
Il 11/09/2018 23:24, Giulio Benetti ha scritto:
> Hello,
> 
> Il 11/09/2018 23:21, James Almer ha scritto:
>>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex 
>>> -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz 
>>> -pthread -latomic -lswresample  -lavutil -lm
>>
>> What i'm seeing here is that -ldrm is apparently present in
>> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
>> that it's strictly listed in the avutil_suggest list.
>>
>> What version of ffmpeg is this script using? Latest git head, an old
>> snapshot, or a release? Did this start failing recently?
> 
> It happens on version 3.4.4 and I haven't foud fixes until master(maybe 
> I've missed something, I'm quite new to this).

Just tried with 4.0.2 and it builds ok.

Sorry I didn't try it before.

So it's only about Buildroot with version 3.4.4

Best regards
Giulio Benetti
James Almer Sept. 11, 2018, 9:34 p.m.
On 9/11/2018 6:24 PM, Giulio Benetti wrote:
> Hello,
> 
> Il 11/09/2018 23:21, James Almer ha scritto:
>>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex
>>> -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz
>>> -pthread -latomic -lswresample  -lavutil -lm
>>
>> What i'm seeing here is that -ldrm is apparently present in
>> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
>> that it's strictly listed in the avutil_suggest list.
>>
>> What version of ffmpeg is this script using? Latest git head, an old
>> snapshot, or a release? Did this start failing recently?
> 
> It happens on version 3.4.4 and I haven't foud fixes until master(maybe
> I've missed something, I'm quite new to this).

This patch does nothing on git master. This is a fix that needs to be
applied to the 3.4 release branch, if anywhere.

> 
>> This patch is a hacky way to add the "-ldrm" ldflag to avutil_extralibs.
>> It should be added organically by configure as part of the dependency
>> checks, so this is definitely not an adequate fix.
> 
> Can you point me the right way to fix this?
> It was the only way I've found to have it working.

I guess it's acceptable in that case. The 3.4 branch had LIBRT and LIBM
hacked into extralibs_avutil, so another one wont hurt. I've pushed it
there.

Thanks.

> 
> Thanks in advance
> Giulio Benetti
Giulio Benetti Sept. 11, 2018, 9:35 p.m.
Il 11/09/2018 23:34, James Almer ha scritto:
> On 9/11/2018 6:24 PM, Giulio Benetti wrote:
>> Hello,
>>
>> Il 11/09/2018 23:21, James Almer ha scritto:
>>>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex
>>>> -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz
>>>> -pthread -latomic -lswresample  -lavutil -lm
>>>
>>> What i'm seeing here is that -ldrm is apparently present in
>>> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
>>> that it's strictly listed in the avutil_suggest list.
>>>
>>> What version of ffmpeg is this script using? Latest git head, an old
>>> snapshot, or a release? Did this start failing recently?
>>
>> It happens on version 3.4.4 and I haven't foud fixes until master(maybe
>> I've missed something, I'm quite new to this).
> 
> This patch does nothing on git master. This is a fix that needs to be
> applied to the 3.4 release branch, if anywhere.
> 
>>
>>> This patch is a hacky way to add the "-ldrm" ldflag to avutil_extralibs.
>>> It should be added organically by configure as part of the dependency
>>> checks, so this is definitely not an adequate fix.
>>
>> Can you point me the right way to fix this?
>> It was the only way I've found to have it working.
> 
> I guess it's acceptable in that case. The 3.4 branch had LIBRT and LIBM
> hacked into extralibs_avutil, so another one wont hurt. I've pushed it
> there.

Oh well, thank it's good to know it's been useful to ffmpeg too.

Best regards
Carl Eugen Hoyos Sept. 11, 2018, 9:38 p.m.
2018-09-11 23:34 GMT+02:00, Giulio Benetti <giulio.benetti@micronovasrl.com>:
> Il 11/09/2018 23:24, Giulio Benetti ha scritto:
>> Hello,
>>
>> Il 11/09/2018 23:21, James Almer ha scritto:
>>>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex
>>>> -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz
>>>> -pthread -latomic -lswresample  -lavutil -lm
>>>
>>> What i'm seeing here is that -ldrm is apparently present in
>>> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
>>> that it's strictly listed in the avutil_suggest list.
>>>
>>> What version of ffmpeg is this script using? Latest git head, an old
>>> snapshot, or a release? Did this start failing recently?
>>
>> It happens on version 3.4.4 and I haven't foud fixes until master(maybe
>> I've missed something, I'm quite new to this).
>
> Just tried with 4.0.2 and it builds ok.

Could you also confirm that it works with current FFmpeg?

Thank you, Carl Eugen
Giulio Benetti Sept. 11, 2018, 9:39 p.m.
Il 11/09/2018 23:38, Carl Eugen Hoyos ha scritto:
> 2018-09-11 23:34 GMT+02:00, Giulio Benetti <giulio.benetti@micronovasrl.com>:
>> Il 11/09/2018 23:24, Giulio Benetti ha scritto:
>>> Hello,
>>>
>>> Il 11/09/2018 23:21, James Almer ha scritto:
>>>>> -lswscale -lavdevice -lavformat -lavcodec -lssl -lcrypto -lspeex
>>>>> -lmodplug -lstdc++ -lfontconfig -lfreetype -lpng16 -lexpat -ldrm -lz
>>>>> -pthread -latomic -lswresample  -lavutil -lm
>>>>
>>>> What i'm seeing here is that -ldrm is apparently present in
>>>> libavdevice.pc, but not in libavutill.pc, which shouldn't happen given
>>>> that it's strictly listed in the avutil_suggest list.
>>>>
>>>> What version of ffmpeg is this script using? Latest git head, an old
>>>> snapshot, or a release? Did this start failing recently?
>>>
>>> It happens on version 3.4.4 and I haven't foud fixes until master(maybe
>>> I've missed something, I'm quite new to this).
>>
>> Just tried with 4.0.2 and it builds ok.
> 
> Could you also confirm that it works with current FFmpeg?
> 

Yes, it build correctly.
This is the end-log:
"
Linking Motion...
--------------------------------------------------------------------------------
/home/giuliobenetti/Desktop/5152dcca58944cf732d09fba6e6c9af8a9243c75/output/host/bin/arm-linux-gcc 
-static -o motion motion.o logger.o conf.o draw.o jpegutils.o 
video_loopback.o video_v4l2.o video_common.o video_bktr.o netcam.o 
netcam_http.o netcam_ftp.o netcam_jpeg.o netcam_wget.o track.o alg.o 
event.o picture.o rotate.o webhttpd.o stream.o md5.o netcam_rtsp.o 
ffmpeg.o  -lm  -pthread -ljpeg -lsqlite3 
-L/home/giuliobenetti/Desktop/5152dcca58944cf732d09fba6e6c9af8a9243c75/output/host/bin/../arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib 
-L/home/giuliobenetti/Desktop/5152dcca58944cf732d09fba6e6c9af8a9243c75/output/host/bin/../arm-buildroot-linux-uclibcgnueabi/sysroot/usr//lib 
-lswscale -lavdevice -lavformat -lmodplug -lstdc++ -lssl -lcrypto 
-lavcodec -lz -lspeex -lswresample  -lavutil -pthread -lm -ldrm
--------------------------------------------------------------------------------
Motion has been linked.
"

So now -ldrm is at the end as expected.

Best regards

Patch hide | download patch | download mbox

diff --git a/configure b/configure
index ef97c6b500..28bc3481bc 100755
--- a/configure
+++ b/configure
@@ -6057,7 +6057,7 @@  enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_
 enabled libcodec2         && require libcodec2 codec2/codec2.h codec2_create -lcodec2
 enabled libdavs2          && require_pkg_config libdavs2 "davs2 >= 1.5.115" davs2.h davs2_decoder_open
 enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
-enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
+enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion && LIBDRM="-ldrm"
 enabled libfdk_aac        && { check_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"; } }
@@ -7347,7 +7347,7 @@  rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}")
 source_path=${source_path}
 LIBPREF=${LIBPREF}
 LIBSUF=${LIBSUF}
-extralibs_avutil="$avutil_extralibs"
+extralibs_avutil="$avutil_extralibs $LIBDRM"
 extralibs_avcodec="$avcodec_extralibs"
 extralibs_avformat="$avformat_extralibs"
 extralibs_avdevice="$avdevice_extralibs"