m-ab-s / media-autobuild_suite

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.
GNU General Public License v3.0
1.49k stars 257 forks source link

[mingw64] [ffmpeg shared] LD fails because of several "multiple definitions" in libplacebo? #2644

Open vt-idiot opened 2 months ago

vt-idiot commented 2 months ago

MABS fails with linker errors for multiple definitions caused by libplacebo? I tried deleting the build folders for ffmpeg-git, libplacebo, and SPIRV. Same issue persists.

11:55:27 ├ Compiling FFmpeg with Vapoursynth R65
11:55:27 ├ FFmpeg will need vapoursynth.dll and vsscript.dll to run using vapoursynth demuxers!
11:55:31   Running git clone for ffmpeg...
11:56:55   Running git update for ffmpeg...
11:57:00 ┌ ffmpeg git  ............................... [Recently updated]
11:57:00 ├ Changing options to comply to nonfree...
11:57:11 ├ Installing clang... done
0001-Add-Alternative-VapourSynth-demuxer.patch
        Patch could not be applied with `git am`. Continuing without patching.
11:57:43 ├ Compiling shared FFmpeg...
11:58:13 ├ Running configure...
13:52:45 ├ Running make...
Likely error (tail of the failed operation logfile):
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x9a0): multiple definition of `pl_vk_inst_create'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000942.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x2830): multiple definition of `pl_vulkan_destroy'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000948.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x31a0): multiple definition of `pl_vulkan_create'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000946.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x4da0): multiple definition of `pl_vulkan_import'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000951.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_gpu.c.obj):gpu.c:(.text+0xc90): multiple definition of `pl_vulkan_get'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000949.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x21f0): multiple definition of `pl_vulkan_wrap'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000960.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x3770): multiple definition of `pl_vulkan_hold_ex'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000950.o):(.text+0x0): first defined here
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x3a20): multiple definition of `pl_vulkan_release_ex'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000955.o):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
make: *** [/build/ffmpeg-git/Makefile:136: ffplay_g.exe] Error 1
make failed. Check J:/media-autobuild_suite-master/build/ffmpeg-git/build-shared-64bit/ab-suite.make.log
This is required for other packages, so this script will exit.
15:05:46   Creating diagnostics file...

Attach J:\media-autobuild_suite-master\build\logs.zip to the GitHub issue.
Make sure the suite is up-to-date before reporting an issue. It might've been fixed already.
Try running the build again at a later time.

I think this is the important bit? Removed the full path from every line except the first one for readability...

Likely error (tail of the failed operation logfile):
J:/media-autobuild_suite-master/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: J:/media-autobuild_suite-master/local64/lib/libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x9a0): multiple definition of `pl_vk_inst_create'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000942.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x2830): multiple definition of `pl_vulkan_destroy'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000948.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x31a0): multiple definition of `pl_vulkan_create'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000946.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_context.c.obj):context.c:(.text+0x4da0): multiple definition of `pl_vulkan_import'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000951.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_gpu.c.obj):gpu.c:(.text+0xc90): multiple definition of `pl_vulkan_get'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000949.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x21f0): multiple definition of `pl_vulkan_wrap'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000960.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x3770): multiple definition of `pl_vulkan_hold_ex'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000950.o):(.text+0x0): first defined here
ld.exe: libplacebo.a(vulkan_gpu_tex.c.obj):gpu_tex.c:(.text+0x3a20): multiple definition of `pl_vulkan_release_ex'; libavfilter/libavfilter.dll.a(avfilter_10_dll_d000955.o):(.text+0x0): first defined here

logs.zip

L4cache commented 2 months ago

I can't even get libplacebo to pass the configure step

vt-idiot commented 2 months ago

I can't even get libplacebo to pass the configure step

Weird. That part seems to work fine on my end. Here's some stuff from \build\libplacebo-git\build-64bit since I'm not sure if logs.zip includes everything or just the logs from the package that failed (ffmpeg). If there's anything else that might help someone figure it out, let me know.

ab-suite.build.log ab-suite.install.log ab-suite.meson.log

and \build\libplacebo-git\build-64bit\meson-private\__CMake_compiler_info__\CMakeFiles\CMakeConfigureLog.yaml.log for good measure?

I know very little about how this all works, but doesn't multiple definition... mean that it's trying to link against libplacebo in a way that it shouldn't?

L4cache commented 2 months ago

Oh I mean the ffmpeg's configure... my bad. libplacebo, even when I was able to build ffmpeg with some time ago, is broken when using -vf libplacebo, at least on my side, so there's definitely something wrong

vt-idiot commented 2 months ago

Oh I mean the ffmpeg's configure... my bad. libplacebo, even when I was able to build ffmpeg with some time ago, is broken when using -vf libplacebo, at least on my side, so there's definitely something wrong

Ah. ffmpeg configure took two hours on my end, but it did finish. If I can tie my computer up for another 8 hours because someone probably made some more cosmetic commits to curl and libass I can try skipping the dynamic/shared ffmpeg compile and going only for static.

-vf libplacebo being broken doesn't bode well since I only care for it in ffmpeg so it can end up in mpv "downstream"

L4cache commented 2 months ago

I was able to build ffmpeg with libplacebo from scratch (using your ffmpeg_option.txt) but it's still crashes when I use -vf libplacebo. However, I think it's not necessary to link libplacebo to the ffmpeg for use in mpv (and tried). mpv can "directly" link libplacebo, it's mpv's own thing (sort of) to begin with.

Andarwinux commented 2 months ago

You can't mix dynamic and static ffmpeg and libplacebo. Either build only static libplacebo and static ffmpeg, or build only dynamic libplacebo and dynamic ffmpeg. https://github.com/haasn/libplacebo/pull/221

vt-idiot commented 2 months ago

However, I think it's not necessary to link libplacebo to the ffmpeg for use in mpv (and tried). mpv can "directly" link libplacebo, it's mpv's own thing (sort of) to begin with.

Thank you @L4cache - I will disable libplacebo in ffmpeg since I never use it there anyways and give it a shot.

Either build only static libplacebo and static ffmpeg, or build only dynamic libplacebo and dynamic ffmpeg. I don't

@Andarwinux I think m-ab-s is only building static libplacebo? It looks like do_meson in media-suite_helper.sh is hardcoded to build static libraries log "meson" meson setup "$root" --default-library=static --buildtype=release \

Andarwinux commented 2 months ago

You can manually append --default-library=shared to override the template args.

vt-idiot commented 2 months ago

I have never once used -vf libplacebo in ffmpeg so I just disabled it entirely in ffmpeg_options.txt which got it to compile.

14:12:39 ├ Compiling FFmpeg with Vapoursynth R65
14:12:39 ├ FFmpeg will need vapoursynth.dll and vsscript.dll to run using vapoursynth demuxers!
14:13:22   Running git update for ffmpeg...
14:13:41 ┌ ffmpeg git  .................................. [Updates found]
14:13:42 ├ Changing options to comply to nonfree...
14:13:55 ├ Installing clang... done
0001-Add-Alternative-VapourSynth-demuxer.patch
        Patch could not be applied with `git am`. Continuing without patching.
14:14:35 ├ Compiling shared FFmpeg...
14:15:17 ├ Running configure...
16:17:27 ├ Running make...
17:39:33 ├ Running install...
17:40:08 ├ Compiling static FFmpeg...
17:40:53 ├ Running configure...

We'll see if this make it all the way to mpv or not, then I'll just close this issue since it appears to be core to how libplacebo itself is compiled on Windows ? and would probably require building libplacebo twice.

If you've come across this issue later and are now reading this, and you build both dynamic and static ffmpeg, make a copy of your ffmpeg_options.txt, call it ffmpeg_options_shared.txt, and comment out # --enable-libplacebo. Your dynamic ffmpeg compile won't have libplacebo.

gitoss commented 1 day ago

The exact same problem like in https://github.com/m-ab-s/media-autobuild_suite/issues/2665 occurs with my build unless I disable libplacebo for the shared build in ffmpeg_options_shared.txt

You can manually append --default-library=shared to override the template args.

Simple /me is new to m-a-s... where exactly do I have to add this to get a shared ffmpeg including libplacebo?

In any case, this is still a bug because either enabling libplacebo in ffmpeg_options.txt should simply work for the static and shared ffmpeg, or if this is impossible there should be a mechanism to auto-disable libplacebo for either the shared|static build

 ffmpeg git  ............................................ [Updates found]
├ Changing options to comply to nonfree...
├ Compiling shared FFmpeg...
├ Running uninstall...
├ Running configure...
├ Running make...
Likely error (tail of the failed operation logfile):
>>> defined at libplacebo.a(common.c.obj)
>>> defined at avfilter-10.dll

ld.lld: warning: duplicate symbol: pl_transform2x2_invert
>>> defined at libplacebo.a(common.c.obj)
>>> defined at avfilter-10.dll

ld.lld: error: pl_bit_encoding_equal was replaced
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/build/ffmpeg-git/Makefile:139: ffplay_g.exe] Error 1
make failed. Check C:/media-autobuild/build/ffmpeg-git/build-shared-64bit/ab-suite.make.log
This is required for other packages, so this script will exit.
  Creating diagnostics file...

Attach C:\media-autobuild\build\logs.zip to the GitHub issue.
Make sure the suite is up-to-date before reporting an issue. It might've been fixed already.