rockchip-linux / mpp

Media Process Platform (MPP) module
466 stars 155 forks source link

multiple definition error when building a project using mpp and libvpx #580

Open MarcA711 opened 2 months ago

MarcA711 commented 2 months ago

Rockchip mpp uses functions with the same name as libvpx. This leads to a multiple definition error when using both, mpp and libvpx, in a project together. Here is the build output when trying to build ffmpeg-rockchip from @nyanmisaka including libvpx:

/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):: (.rodata+0x0): multiple definition of `vp9_kf_partition_probs'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x190)/opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata+0x0): multiple definition of `vp9_kf_partition_probs'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(: first defined here
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata.rodata+0x30): multiple definition of `vp9_kf_uv_mode_prob'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x+0x190): first defined here
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld1c0: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata+0x)30): multiple definition of `vp9_kf_uv_mode_prob: first defined here'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x
1c0): first defined here/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata: +0xb0): multiple definition of `vp9_kf_y_mode_prob'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata/opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(+0x.rodata220): first defined here+0x
b0): multiple definition of `vp9_kf_y_mode_prob'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x220): first defined here
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata+0x0): multiple definition of `vp9_kf_partition_probs'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x190): first defined here
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata+0x30): multiple definition of `vp9_kf_uv_mode_prob'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x1c0): first defined here
/opt/ct-ng/lib/gcc/aarch64-ffbuild-linux-gnu/13.2.0/../../../../aarch64-ffbuild-linux-gnu/bin/ld: /opt/ffbuild/lib/librockchip_mpp.a(hal_vp9d_com.c.o):(.rodata+0xb0): multiple definition of `vp9_kf_y_mode_prob'; /opt/ffbuild/lib/libvpx.a(vp9_entropymode.c.o):(.rodata+0x220): first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:133: ffmpeg_g] Error 1
make: *** Waiting for unfinished jobs....
collect2: error: ld returned 1 exit status
make: *** [Makefile:133: ffprobe_g] Error 1
collect2: error: ld returned 1 exit status
make: *** [Makefile:133: ffplay_g] Error 1

I propose to rename the functions that are also used in the libvpx project (maybe prefix them with mpp_).

It seems, that there were files copied from the libvpx project (similar to https://github.com/rockchip-linux/mpp/issues/530). Note, that libvpx is licensed under BSD-3-Clause license. As far as I know, this license allows to modify the source code of libvpx and include it in your project, but it obliges you to add a copy of the BSD license to your project. Maybe it is enough to just add the BSD license as a comment to the source code.

HermanChen commented 2 months ago

I know this is also the same issue mentioned by ffmpeg. We use some ffmpeg and libvpx code in parser. We have to replace the code or fix the license but it is delayed for rk3576 support work.