Skip to content
Anime4000 edited this page Dec 2, 2019 · 13 revisions

Compile x265 for IFME

In this guide, you will able to compile for Internet Friendly Media Encoder and it will generate 8bit, 10bit and 12bit.

  • MSYS
  • Visual Studio 2013
  • Visual Studio 2015
  • Intel C Compiler 2016 (with Visual Studio 2013)
  • Extra: Linux GCC

Before Start

Install these:

Make sure yasm.exe is installed on Windows folder, not system32 or SysWOW64

Compile

MSYS

make-ifme.sh

#!/bin/sh

# This script for building x265 for Internet Friendly Media Encoder
# compiled binaries will place here

# 8bit
cmake -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
make
mv x265.exe x265-08.exe

# 10bit
cmake -G "MSYS Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake ../../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_TOOLCHAIN_FILE=toolchain-x86_64-w64-mingw32.cmake ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
make
mv x265.exe x265-12.exe

MSYS2

make-ifme.sh

#!/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.2.0:
# pacman -S --needed base-devel git subversion mercurial nasm yasm mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-qt5

# MSYS2 have problem with CMake and HG to get version, this script will make .hg_archival.txt by tricking CMake
HG_ARCHIVAL="../../.hg_archival.txt"

REPO=`hg log -r. --template {node}`
NODE=`hg log -r. --template {node}`
BRANCH=`hg log -r. --template {branch}`
TAG=`hg log -r. --template {latesttag}`
DISTANCE=`hg log -r. --template {latesttagdistance}`

echo -e repo: ${REPO} > $HG_ARCHIVAL
echo -e node: ${NODE:0:12} >> $HG_ARCHIVAL
echo -e branch: ${BRANCH} >> $HG_ARCHIVAL
echo -e tag: ${TAG}+${DISTANCE}_ifme-znver2 >> $HG_ARCHIVAL
echo -e distance: ${DISTANCE} >> $HG_ARCHIVAL

# 8bit
cmake -G "MSYS Makefiles" -DCMAKE_AR=/mingw64/bin/ar -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -march=znver2 -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -march=znver2 -static" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
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 -march=znver2 -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -march=znver2 -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 -march=znver2 -static" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -march=znver2 -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

Visual Studio 2013

build-ifme.cmd

:: This script for building x265 for Internet Friendly Media Encoder
:: compiled binaries will placed on "Release" folder
@echo off
if "%VS120COMNTOOLS%" == "" (
  msg "%username%" "Visual Studio 12 not detected"
  exit 1
)

call "%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat"

:: 8 bit
cmake -G "Visual Studio 12 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-08.exe
)

:: 10bit
cmake -G "Visual Studio 12 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=OFF
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-10.exe
)

:: 12bit
cmake -G "Visual Studio 12 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-12.exe
)

Visual Studio 2015

build-ifme.cmd

:: This script for building x265 for Internet Friendly Media Encoder
:: compiled binaries will placed on "Release" folder
@echo off
if "%VS140COMNTOOLS%" == "" (
  msg "%username%" "Visual Studio 14 not detected"
  exit 1
)

call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat"

:: 8 bit
cmake -G "Visual Studio 14 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-08.exe
)

:: 10bit
cmake -G "Visual Studio 14 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=OFF
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-10.exe
)

:: 12bit
cmake -G "Visual Studio 14 Win64" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
if exist x265.sln (
  MSBuild /property:Configuration="Release" x265.sln
  move /y Release\x265.exe Release\x265-12.exe
)

Use Intel instead of Microsoft compiler

Add -T "Intel C++ Compiler XE 16.0" after -G "Visual Studio 14 Win64" in order to use Intel Compiler via Visual Studio. Note

Intel C Compiler 2016

make-ifme.cmd

@echo off
::
:: run this batch file to create an Intel C++ 2016 NMake makefile for this project.
:: See the cmake documentation for other generator targets
::

if "%VS120COMNTOOLS%" == "" (
  msg "%username%" "Visual Studio 12 not detected"
  exit 1
)

if "%ICPP_COMPILER16%" == "" (
  msg "%username%" "Intel C++ 2016 not detected"
  pause
  exit 1
)

call "%ICPP_COMPILER16%\bin\compilervars.bat" intel64

set CC=icl /Qstd=c++11 /Qoption,cpp,--no_user_defined_literals
set CXX=icl /Qstd=c++11 /Qoption,cpp,--no_user_defined_literals

:: 8bit
cmake -G "NMake Makefiles" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
nmake
move /y x265.exe x265-08.exe

:: 10bit
cmake -G "NMake Makefiles" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=OFF
nmake
move /y x265.exe x265-10.exe

:: 12bit
cmake -G "NMake Makefiles" ..\..\source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
nmake
move /y x265.exe x265-12.exe

pause

Extra: Linux GCC

make-ifme.bash

#!/bin/bash
# Run this from within a bash shell

# 8bit
cmake -G "Unix Makefiles" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON
make
mv x265 x265-08

# 10bit
cmake -G "Unix Makefiles" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=OFF
make
mv x265 x265-10

# 12bit
cmake -G "Unix Makefiles" ../../source -DENABLE_SHARED=OFF -DSTATIC_LINK_CRT=ON -DENABLE_CLI=ON -DHIGH_BIT_DEPTH=ON -DMAIN12=ON
make
mv x265 x265-12

echo "DONE!"