Like before, I using msys XhmikosR Builds, but it come with GCC 7.1.0, however msys2 has latest GCC, plus with pacman (Package Manager) which is look like Debian apt install
on Ubuntu.
I building x265 under msys2 and latest GCC can take maximum performance on modern CPU like Ryzen 7. You can download msys2 from here, but it come with minimal package, need run several commands to make basic build environment.
NOTE!!!
msys2 is just like linux, make sure your Windows Username do not contain space!
Update msys2
After install, run this command first:
pacman -Syu
Press Y and wait until you see this screen, simply exit terminal without CTRL+C
Update package
Open msys2 (I use 64-bit) and run this command, and wait until it finished.
pacman -Su
Download build-essential
For making working x265, require:
- base-devel
- git
- subversion
- mercurial
- nasm yasm
64-bit GCC Builds
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-qt5
mingw-w64-cross-binutils
Command as follow:
pacman -S --needed base-devel git subversion mercurial nasm yasm cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-qt5 mingw-w64-cross-binutils
32-bit GCC Builds
mingw-w64-i686-toolchain
mingw-w64-i686-cmake
mingw-w64-i686-qt5
mingw-w64-cross-binutils
Command as follow:
pacman -S --needed base-devel git subversion mercurial nasm yasm mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-qt5 mingw-w64-cross-binutils
Fixes
Some make use prefixes, so need do this in MSYS2 Terminal
ln -s /mingw64/bin/windres /mingw64/bin/x86_64-w64-mingw32-windres
Build x265
Navigate to msys2 home folder by enter cd ~
in terminal, and start clone x265 project:
git clone https://bitbucket.org/multicoreware/x265_git.git
After complete git clone
, enter folder x265_git/build
and make new folder, for example ifme
Make new compile.sh
file and paste this code:
#!/bin/sh
# This script for building x265 for Internet Friendly Media Encoder
# Make a new folder under "x265/build/msys2"
# This script will run under MSYS2 (https://www.msys2.org/)
# with complete development package, GCC 9.3.0:
# pacman -S --needed base-devel git subversion mercurial nasm yasm cmake mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-qt5
# Run this script under MSYS MINGW64 !!!
# 8bit
cmake -G "MSYS Makefiles" -DCMAKE_AR=/mingw64/bin/ar -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -static" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=OFF -DMAIN12=OFF
make
mv x265.exe x265-08.exe
# 10bit
cmake -G "MSYS Makefiles" -DCMAKE_AR=/mingw64/bin/ar -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -static" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=OFF
make
mv x265.exe x265-10.exe
# 12bit
cmake -G "MSYS Makefiles" -DCMAKE_AR=/mingw64/bin/ar -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -static" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
make
mv x265.exe x265-12.exe
Save and execute by typing sh compile.sh
Wait and enjoy x265 compile under latest GCC 🙂