Skip to content

Commit 83adc86

Browse files
committed
Build shared FFmpeg on Linux and set dependencies to stubs
Pick-to: 6.8 Task-number: QTBUG-120990 Change-Id: I8fccf8ef58cf6334e71287450ee30cc2256516d9 Reviewed-by: Volker Hilsheimer <[email protected]>
1 parent 2764cde commit 83adc86

File tree

10 files changed

+72
-9
lines changed

10 files changed

+72
-9
lines changed

coin/platform_configs/address_sanitizer_platforms.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ Configurations:
88
Configure arguments: '-nomake examples -developer-build'
99
Environment variables: [
1010
'CMAKE_ARGS=-DOPENSSL_ROOT_DIR={{.Env.OPENSSL_HOME}}',
11-
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}'
11+
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE'
1212
]

coin/platform_configs/cmake_platforms.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Configurations:
1414
Compiler: 'GCC'
1515
Features: ['Sccache', 'Documentation', 'UseConfigure', 'DoNotRunTests']
1616
Configure arguments: '-make examples -developer-build -c++std c++20 -linker gold -qtlibinfix TestInfix -qtnamespace TestNamespace'
17-
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}']
17+
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE']
1818
-
1919
Id: 'ubuntu-22.04'
2020
Template: 'qtci-linux-Ubuntu-22.04-x86_64-51'
@@ -23,7 +23,7 @@ Configurations:
2323
Configure arguments: '-nomake examples -release -force-debug-info -separate-debug-info -headersclean -qt-libjpeg -qt-libpng -qt-pcre -qt-harfbuzz -qt-doubleconversion -no-libudev -bundled-xcb-xinput'
2424
Environment variables: [
2525
'CMAKE_ARGS=-DOpenGL_GL_PREFERENCE=LEGACY',
26-
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DINPUT_headersclean=ON'
26+
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DINPUT_headersclean=ON -DQT_DEPLOY_FFMPEG=TRUE'
2727
]
2828
# Test on Ubuntu 22.04 X11
2929
-
@@ -68,7 +68,7 @@ Configurations:
6868
Compiler: 'GCC'
6969
Features: ['Sccache', 'Documentation', 'UseConfigure', 'DoNotRunTests']
7070
Configure arguments: '-make examples -developer-build -c++std c++20 -linker gold -qtlibinfix TestInfix -qtnamespace TestNamespace'
71-
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}']
71+
Environment variables: ['NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE']
7272
-
7373
Id: 'ubuntu-24.04-x64'
7474
Template: 'qtci-linux-Ubuntu-24.04-x86_64-50'
@@ -77,7 +77,7 @@ Configurations:
7777
Configure arguments: '-nomake examples -release -force-debug-info -separate-debug-info -headersclean -qt-libjpeg -qt-libpng -qt-pcre -qt-harfbuzz -qt-doubleconversion -no-libudev -bundled-xcb-xinput'
7878
Environment variables: [
7979
'CMAKE_ARGS=-DOpenGL_GL_PREFERENCE=LEGACY',
80-
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DINPUT_headersclean=ON'
80+
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE -DINPUT_headersclean=ON'
8181
]
8282
# Test on Ubuntu 24.04 x64 X11
8383
-
@@ -101,7 +101,7 @@ Configurations:
101101
Environment variables: [
102102
'PATH={{.Env.CMAKE_MIN_SUPPORTED_BIN_PATH}}:{{.Env.PATH}}',
103103
'CMAKE_ARGS=-DOPENSSL_ROOT_DIR={{.Env.OPENSSL_HOME}}',
104-
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}}'
104+
'NON_QTBASE_CMAKE_ARGS=-DFFMPEG_DIR={{.Env.FFMPEG_DIR}} -DQT_DEPLOY_FFMPEG=TRUE'
105105
]
106106
-
107107
Id: 'sles-15_sp5-static'
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
# Copyright (C) 2024 The Qt Company Ltd.
3+
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4+
5+
set -x
6+
7+
lib_dir="$1/lib"
8+
9+
ffmpeg_libs=("avcodec" "avdevice" "avfilter" "avformat" "avutil" "swresample" "swscale")
10+
11+
for lib_name in "${ffmpeg_libs[@]}"; do
12+
lib_path="$lib_dir/lib$lib_name.so"
13+
pkg_config_file_path="$lib_dir/pkgconfig/lib$lib_name.pc"
14+
15+
if [ ! -f "$lib_path" ]; then
16+
echo "FFmpeg lib $lib_path hasn't been found"
17+
exit 1
18+
fi
19+
20+
if [ ! -f "$pkg_config_file_path" ]; then
21+
echo "FFmpeg pc file $pkg_config_file_path hasn't been found"
22+
exit 1
23+
fi
24+
25+
while read -r line; do
26+
if [[ $line =~ .*\[(lib((ssl|crypto|va|va-x11|va-drm)\.so(\.[0-9]+)*))\].* ]]; then
27+
patchelf --replace-needed "${BASH_REMATCH[1]}" "libQt6FFmpegStub-${BASH_REMATCH[2]}" $lib_path
28+
fi
29+
done <<< "$(readelf -d $lib_path | grep '(NEEDED)' )"
30+
31+
sed -i -E "/^Libs.private:/s/ -l(va|va-x11|va-drm|ssl|crypto)/ -lQt6FFmpegStub-\\1/g;" $pkg_config_file_path
32+
patchelf --set-rpath '$ORIGIN' $lib_path
33+
done

coin/provisioning/common/unix/install-ffmpeg.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,31 @@ build_ffmpeg() {
7171
}
7272

7373
if [ "$os" == "linux" ]; then
74+
# TODO: install patchelf on RHEL and remove the force "static"
75+
if [ -f "/etc/redhat-release" ]; then
76+
build_type="static"
77+
else
78+
build_type="$2"
79+
fi
80+
7481
install_ff_nvcodec_headers
7582

7683
ffmpeg_config_options+=" --enable-openssl"
84+
85+
if [ "$build_type" != "static" ]; then
86+
ffmpeg_config_options+=" --enable-shared --disable-static"
87+
fi
88+
7789
build_ffmpeg
78-
sudo mv "$ffmpeg_source_dir/build/installed/usr/local/$ffmpeg_name" "/usr/local"
90+
91+
output_dir="$ffmpeg_source_dir/build/installed/usr/local/$ffmpeg_name"
92+
93+
if [ "$build_type" != "static" ]; then
94+
fix_dependencies="${BASH_SOURCE%/*}/../linux/fix_ffmpeg_dependencies.sh"
95+
"$fix_dependencies" "$output_dir"
96+
fi
97+
98+
sudo mv "$output_dir" "/usr/local"
7999
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
80100

81101
elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
@@ -111,3 +131,5 @@ elif [ "$os" == "macos" ] || [ "$os" == "macos-universal" ]; then
111131

112132
SetEnvVar "FFMPEG_DIR" "/usr/local/$ffmpeg_name"
113133
fi
134+
135+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux"
3+
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux" "static"

coin/provisioning/qtci-linux-SLES-15_SP5-x86_64/90-install-ffmpeg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright (C) 2023 The Qt Company Ltd
33
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
44

5-
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux"
5+
source "${BASH_SOURCE%/*}/../common/unix/install-ffmpeg.sh" "linux" "static"

coin/provisioning/qtci-linux-Ubuntu-18.04-x86_64/02-apt.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ installPackages+=(ruby)
168168
installPackages+=(libxslt1-dev)
169169
installPackages+=(libxml2-dev)
170170
installPackages+=(libhyphen-dev)
171+
# Fix dependencies in shared ffmpeg libs
172+
installPackages+=(patchelf)
171173

172174
echo "Running update for apt"
173175
waitLoop

coin/provisioning/qtci-linux-Ubuntu-20.04-x86_64/02-apt.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ sudo dpkg --add-architecture i386
217217
installPackages+=(nfs-kernel-server)
218218
installPackages+=(net-tools)
219219
installPackages+=(bridge-utils)
220+
# Fix dependencies in shared ffmpeg libs
221+
installPackages+=(patchelf)
220222

221223
echo "Running update for apt"
222224
waitLoop

coin/provisioning/qtci-linux-Ubuntu-22.04-x86_64/02-apt.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ installPackages+=(uml-utilities)
233233
# used for reading vcpkg packages version, from vcpkg.json
234234
installPackages+=(jq)
235235

236+
installPackages+=(patchelf)
237+
236238
echo "Running update for apt"
237239
waitLoop
238240
sudo apt-get update

coin/provisioning/qtci-linux-Ubuntu-24.04-x86_64/02-apt.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ installPackages+=(uml-utilities)
238238
# used for reading vcpkg packages version, from vcpkg.json
239239
installPackages+=(jq)
240240

241+
installPackages+=(patchelf)
242+
241243
echo "Running update for apt"
242244
waitLoop
243245
sudo apt-get update

0 commit comments

Comments
 (0)