fix: 修复 mpp 库静态构建错误

This commit is contained in:
mofeng-git
2026-06-20 21:28:01 +08:00
parent f1e362a820
commit 6c1bff5d0c
3 changed files with 12 additions and 16 deletions

View File

@@ -274,6 +274,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
&& make -j$(nproc) \
&& make install \
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/aarch64-linux-gnu/lib/pkgconfig/rockchip_mpp.pc \
&& rm -f /usr/aarch64-linux-gnu/lib/librockchip_mpp.so* \
&& cd ../.. \
# Build RKRGA - create cross file for meson
&& echo '[binaries]' > /tmp/aarch64-cross.txt \
@@ -301,6 +302,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
&& ar rcs /usr/aarch64-linux-gnu/lib/librga.a $(find build -name '*.o') \
&& ranlib /usr/aarch64-linux-gnu/lib/librga.a \
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/aarch64-linux-gnu/lib/pkgconfig/librga.pc \
&& rm -f /usr/aarch64-linux-gnu/lib/librga.so* \
&& cd .. \
# Create pkg-config wrapper for cross-compilation
&& echo '#!/bin/sh' > /tmp/aarch64-pkg-config \
@@ -407,4 +409,4 @@ ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
LIBYUV_STATIC=1 \
OPUS_STATIC=1 \
PKG_CONFIG_ALL_STATIC=1 \
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc"
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-Wl,--allow-multiple-definition"

View File

@@ -263,6 +263,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
&& make -j$(nproc) \
&& make install \
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/arm-linux-gnueabihf/lib/pkgconfig/rockchip_mpp.pc \
&& rm -f /usr/arm-linux-gnueabihf/lib/librockchip_mpp.so* \
&& cd ../.. \
# Build RKRGA - create cross file for meson
&& echo '[binaries]' > /tmp/armhf-cross.txt \
@@ -290,6 +291,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
&& ar rcs /usr/arm-linux-gnueabihf/lib/librga.a $(find build -name '*.o') \
&& ranlib /usr/arm-linux-gnueabihf/lib/librga.a \
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/arm-linux-gnueabihf/lib/pkgconfig/librga.pc \
&& rm -f /usr/arm-linux-gnueabihf/lib/librga.so* \
&& cd .. \
# Create pkg-config wrapper for cross-compilation
&& echo '#!/bin/sh' > /tmp/armhf-pkg-config \
@@ -396,7 +398,7 @@ ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
LIBYUV_STATIC=1 \
OPUS_STATIC=1 \
PKG_CONFIG_ALL_STATIC=1 \
RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc"
RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc -C link-arg=-Wl,--allow-multiple-definition"
# Default command
CMD ["bash"]

View File

@@ -338,7 +338,7 @@ mod ffmpeg {
println!("cargo:rustc-link-lib=static=avcodec");
println!("cargo:rustc-link-lib=static=avutil");
// Link hardware acceleration dependencies (dynamic)
// Link hardware acceleration dependencies
// These vary by architecture
if target_arch == "x86_64" {
// VAAPI for x86_64
@@ -347,13 +347,11 @@ mod ffmpeg {
println!("cargo:rustc-link-lib=va-x11"); // Required for vaGetDisplay
println!("cargo:rustc-link-lib=mfx");
} else {
// RKMPP for ARM
println!("cargo:rustc-link-lib=rockchip_mpp");
let rga_static = lib_dir.join("librga.a");
if rga_static.exists() {
println!("cargo:rustc-link-lib=static=rga");
} else {
println!("cargo:rustc-link-lib=rga");
for lib in ["rockchip_mpp", "rga"] {
if !lib_dir.join(format!("lib{lib}.a")).exists() {
panic!("missing static library: lib{lib}.a");
}
println!("cargo:rustc-link-lib=static={}", lib);
}
}
@@ -412,12 +410,6 @@ mod ffmpeg {
// For static linking, link FFmpeg libs statically, others dynamically
if lib_name.starts_with("av") || lib_name == "swresample" {
println!("cargo:rustc-link-lib=static={}", lib_name);
} else if lib_name == "rga"
&& link_paths
.iter()
.any(|path| Path::new(path).join("librga.a").exists())
{
println!("cargo:rustc-link-lib=static=rga");
} else {
// Runtime libraries (va, drm, etc.) must be dynamic
println!("cargo:rustc-link-lib={}", lib_name);