FIX for "undefined reference to 'av_mallocz_array"

The place to discuss linux version of MakeMKV
Post Reply
Message
Author
nrk666
Posts: 2
Joined: Mon Feb 27, 2023 1:59 pm

FIX for "undefined reference to 'av_mallocz_array"

#1 Post by nrk666 » Mon Feb 27, 2023 2:09 pm

When compiling makemkv-oss against latest ffmpeg with libfdk-aac, "av_mallocz_array" has been deprecated in ffmpeg https://patchwork.ffmpeg.org/project/ff ... tlook.com/ .

The fix for this is to edit makemkv-oss source file libffabi/src/ffabi.c and replace "av_mallocz_array" with "av_calloc" and recompile.

cas206
Posts: 15
Joined: Mon May 17, 2021 7:20 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#2 Post by cas206 » Mon Mar 27, 2023 7:34 pm

Same error on Linux Mint 21.1. This fix worked. Thanks.

fang2811
Posts: 1
Joined: Wed Mar 29, 2023 2:00 am

Re: FIX for "undefined reference to 'av_mallocz_array"

#3 Post by fang2811 » Wed Mar 29, 2023 2:42 am

I encountered the same compile error on archlinux today.

Code: Select all

> pacman -Q ffmpeg openssl expat mesa qt5-base zlib gcc
ffmpeg 2:6.0-4
openssl 3.0.8-1
expat 2.5.0-1
mesa 23.0.1-1
qt5-base 5.15.8+kde+r185-1
zlib 1:1.2.13-2
gcc 12.2.1-2
Here's the specific patch that I applied (based on nrk666's comment)

Code: Select all

diff --git a/libffabi/src/ffabi.c b/libffabi/src/ffabi.c
index 5dda9e1..2b29b87 100644
--- a/libffabi/src/ffabi.c
+++ b/libffabi/src/ffabi.c
@@ -478,7 +478,7 @@ FFM_AudioEncodeContext* __cdecl ffm_audio_encode_init(void* logctx,const char* n
 #else
     ctx->frame = av_frame_alloc();
     if (av_sample_fmt_is_planar(ctx->avctx->sample_fmt)) {
-        ctx->frame_extended_data = av_mallocz_array(ctx->avctx->channels,
+        ctx->frame_extended_data = av_calloc(ctx->avctx->channels,
             sizeof(*ctx->frame_extended_data));
         if (!ctx->frame_extended_data) {
             ffm_audio_encode_close(ctx);

Falco
Posts: 27
Joined: Thu Aug 16, 2018 6:37 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#4 Post by Falco » Fri Apr 21, 2023 6:55 pm

Same on Fedora Linux fresh installation
Thx nrk666 for your trick to solve this issue.
I posted your correction on my post too,
viewtopic.php?f=3&t=30126&p=135117#p135117

STARBASEn
Posts: 1
Joined: Fri Apr 21, 2023 10:13 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#5 Post by STARBASEn » Fri Apr 21, 2023 10:29 pm

I had the same issue today compiling a later download of v1.17.3 for Fedora38 during make, ffabi, undefined variable av_malloc_arrayz, line 481. I just deleted the trailing z and it compiled fine. So it seems both fixes work, at least for now.

Falco
Posts: 27
Joined: Thu Aug 16, 2018 6:37 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#6 Post by Falco » Sun Apr 23, 2023 11:53 am

Ahah, too cool !
But guys, which is the best value in that case: "av_calloc" or "av_malloc_array" ?

Zirias
Posts: 22
Joined: Mon Apr 22, 2019 3:30 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#7 Post by Zirias » Sat May 13, 2023 5:56 am

Falco wrote:
Sun Apr 23, 2023 11:53 am
But guys, which is the best value in that case: "av_calloc" or "av_malloc_array" ?
The function now removed was named "mallocz", the z means "zero out the memory". If the code relies on the memory being initialized to 0, using "av_malloc_array" instead would most likely lead to crashes.

"av_calloc" OTOH seems to be named after the C standard function "calloc" which DOES zero memory. It's certainly the correct replacement.

Falco
Posts: 27
Joined: Thu Aug 16, 2018 6:37 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#8 Post by Falco » Sat May 13, 2023 4:47 pm

Thank you a lot for this really interesting answer. In that case, I will modify my code with it.

mfraz74
Posts: 20
Joined: Wed Feb 07, 2018 11:16 am

Re: FIX for "undefined reference to 'av_mallocz_array"

#9 Post by mfraz74 » Wed Jun 07, 2023 11:35 am

Just tried compiling 1.17.4 and came across this error. Thanks for the fix.

If you want a simple one liner to change this:

Code: Select all

sed -i "s/av_mallocz_array/av_calloc/g" libffabi/src/ffabi.c

nrk666
Posts: 2
Joined: Mon Feb 27, 2023 1:59 pm

Re: FIX for "undefined reference to 'av_mallocz_array"

#10 Post by nrk666 » Sun Jun 11, 2023 3:32 pm

I forgot I even submitted this, glad I could help out and return a little love for this app. :D :D :D

Post Reply