Last active
August 21, 2023 01:42
-
-
Save ttsuki/600b259879b7a7605747998fa723cf21 to your computer and use it in GitHub Desktop.
Alternative x265/build/msys/multilib.sh (link statically libstdc++)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
PREFIX=$HOME/x265 | |
MAKEFLAGS=-j16 | |
rm -rf build | |
mkdir -p build/{10bit,12bit} | |
cd build | |
# build 10bit static library. | |
cd 10bit | |
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../../toolchain-x86_64-w64-mingw32.cmake ../../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF | |
make ${MAKEFLAGS} | |
cp libx265.a ../libx265_main10.a | |
cd .. | |
# build 12bit static library. | |
cd 12bit | |
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../../toolchain-x86_64-w64-mingw32.cmake ../../../../source -DHIGH_BIT_DEPTH=ON -DEXPORT_C_API=OFF -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DMAIN12=ON | |
make ${MAKEFLAGS} | |
cp libx265.a ../libx265_main12.a | |
cd .. | |
# build 8bit static library | |
cmake -G 'Unix Makefiles' -DCMAKE_TOOLCHAIN_FILE=../toolchain-x86_64-w64-mingw32.cmake ../../../source -DCMAKE_INSTALL_PREFIX="$PREFIX" -DEXTRA_LIB="x265_main10.a;x265_main12.a" -DEXTRA_LINK_FLAGS=-L. -DLINKED_10BIT=ON -DLINKED_12BIT=ON | |
make ${MAKEFLAGS} x265-static | |
# rename the 8bit library, then combine all three into libx265.a using GNU ar | |
mv libx265.a libx265_main.a | |
x86_64-w64-mingw32-ar -M <<EOF | |
CREATE libx265.a | |
ADDLIB libx265_main.a | |
ADDLIB libx265_main10.a | |
ADDLIB libx265_main12.a | |
SAVE | |
END | |
EOF | |
# build all-in shared library and cli. | |
sed -i CMakeFiles/x265-shared.dir/link.txt -e 's/g++.exe/g++.exe -static -static-libgcc -static-libstdc++/' | |
sed -i CMakeFiles/cli.dir/link.txt -e 's/g++.exe/g++.exe -static -static-libgcc -static-libstdc++/' | |
sed -i CMakeFiles/x265-shared.dir/linklibs.rsp -e 's/-Wl,-Bdynamic//' | |
sed -i CMakeFiles/cli.dir/linklibs.rsp -e 's/-Wl,-Bdynamic//' | |
make ${MAKEFLAGS} | |
cd .. | |
echo Do \'make -C build install\' to install. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment