- 1. Prerequisites
- 2. Preparing Dependencies
- 3. Building SRT
The following are the recommended prerequisites to build srt
on Windows.
- CMake v2.8.12 or higher (cross-platform family of tools to build software)
- git client (source code management tool)
- Visual Studio (compiler and linker)
SRT has an external dependency on cryptographic library.
This dependency can be disabled by -DENABLE_ENCRYPTION=OFF
CMake build option.
With disabled encryption SRT will be unable to establish secure connections,
only unencrypted mode can be used.
With the enabled SRT encryption, one of the following Crypto libraries is required:
OpenSSL
(default)LibreSSL
MbedTLS
SRT as of v1.4.2 supports two threading libraries:
- Standard C++ thread library available in C++11 (default on Windows)
pthreads
(not recommended on Windows)
The pthreads
library is provided out-of-the-box on all POSIX-based systems.
On Windows it can be provided as a 3rd party library (see below).
However the C++ standard thread library is recommended to be used on Windows.
Can be used to:
- build OpenSSL library (dependency of SRT).
- build pthreads library (dependency of SRT).
vcpkg is a C++ library manager for Windows, Linux and MacOS. Consider its prerequisites before proceeding.
The vcpkg
library manager has preconfigured building procedures for OpenSSL
and pthreads
libraries.
They can be easily built and further used as dependencies of SRT library.
Note! vcpkg
does not support LibreSSL
or MbedTLS
libraries.
Clone vcpkg
using git, and build it.
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
The current working directory will further be referenced as VCPKG_ROOT
.
set VCPKG_ROOT=%cd%
NuGet package manager can be used to get a prebuilt version of pthreads
library for Windows.
Download nuget CLI to the desired folder.
The directory with NuGet will further be referenced as NUGET_ROOT
.
set NUGET_ROOT=%cd%
To build SRT with support for encryption, one of the following Crypto libraries is required:
OpenSSL
(recommended)LibreSSL
MbedTLS
Note! The vcpkg
working directory is referenced as VCPKG_ROOT
.
Building openssl
library using x64 toolset:
cd VCPKG_ROOT
vcpkg install openssl --triplet x64-windows
The next step is to integrate vcpkg
with the build system, so that CMake
can locate openssl
library.
vcpkg integrate install
CMake will be able to find openssl given the following option is provided:
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
The 64-bit OpenSSL package for Windows can be downloaded using the following link: Win64OpenSSL_Light-1_1_1c.
Note! The last letter or version number may change and older versions may become no longer available. In that case find the appropriate installer here: Win32OpenSSL.
Download and run the installer. The library is expected to be installed in C:\Program Files\OpenSSL-Win64
. Add this path to the user's or system's environment variable PATH
.
It's expected to be installed in C:\OpenSSL-Win64
.
Note that this version is most likely compiled for Visual Studio 2013. For other versions please follow instructions in Section 2.1.1.3 Build from Sources.
Download and compile the sources from the OpenSSL website. The instructions for compiling on Windows can be found here: link.
Note! ActivePerl
and nasm
are required to build OpenSSL.
MbedTLS
source code can be downloaded from the website.
MbedTLS
comes with cmake
build system support. Use the CMAKE_INSTALL_PREFIX
variable to specify the directory that will contain the MbedTLS
headers and libraries. Note that building MbedTLS
as a DLL is broken in version 2.16.3. You have to link it statically.
LibreSSL has header files that are compatible with OpenSSL, CMake can use it like OpenSSL with little configuration. The source code and binaries can be downloaded from here: link.
Since there are no recent Windows builds, the only option is to build a new version from sources.
LibreSSL comes with CMake build system support. Use the CMAKE_INSTALL_PREFIX
variable
to specify the directory that will contain the LibreSSL headers and libraries.
SRT can use one of these two threading libraries:
- C++11 threads (SRT v1.4.2 and above) - recommended, default since SRT v1.4.4;
pthreads
(not recommended on Windows).
To be able to use the standard C++ threading library (available since C++11)
specify the CMake option -DENABLE_STDCXX_SYNC=ON
.
This way there will be also no external dependency on the threading library.
Otherwise the external PThreads for Windows wrapper library is required.
It is not recommended to use pthreads
port on Windows. Consider using C++11 instead,
Note! The vcpkg
working directory is referenced as VCPKG_ROOT
.
Build the pthreads
library using the x64 toolset:
vcpkg install pthreads --triplet x64-windows
The next step is to integrate vcpkg
with the build system, so that CMake
can locate pthreads
library.
vcpkg integrate install
Now go to the srt-xtransmit
cloned folder XTRANSMIT_ROOT
and run cmake
to generate build configuration files.
CMake will be able to find openssl given the following option is provided:
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
This step assumes the NuGet is available from the NUGET_ROOT
folder
(refer to 1.3.2. NuGet Manager (optional)).
Run nuget
to install pthreads
to the specified path.
In the example below the library will be installed in C:\pthread-win32
.
nuget install cinegy.pthreads-win64 -version 2.9.1.17 -OutputDirectory C:\pthread-win32
Two CMake options have to be provided on the step 3.2. Generate Build Files.
-DPTHREAD_INCLUDE_DIR="C:\pthread-win32\cinegy.pthreads-win64.2.9.1.17\sources"
-DPTHREAD_LIBRARY="C:\pthread-win32\cinegy.pthreads-win64.2.9.1.17\runtimes\win-x64\native\release\pthread_lib.lib"
Download the source code from SourceForge (link) and follow the build instructions.
Compile and install pthread-win32
for Windows from GitHub: link.
- Using Visual Studio 2013, open the project file
pthread_lib.2013.vcxproj
- Select configuration:
Release
andx64
. - Make sure that the
pthread_lib
project will be built. - After building, find the
pthread_lib.lib
file (directory is usuallybin\x64_MSVC2013.Release
). Copy this file toC:\pthread-win32\lib
(or whatever other location you configured in variables). - Copy include files to
C:\pthread-win32\include
(pthread.h
,sched.h
, andsemaphore.h
are in the toplevel directory. There are no meaningful subdirs here). Note thatwin##
is part of the project name. It will becomewin32
orwin64
depending on the selection.
Retrieve the SRT source code from GitHub using a git client.
git clone --branch <tag_name> https://github.com/haivision/srt.git srt
cd srt
set SRT_ROOT=%cd%
where --branch <tag_name>
can be used to define a specific release version of SRT,
e.g. --branch v1.4.1
.
Note! The current working directory will further be referenced as SRT_ROOT
.
If --branch <tag_name>
is omitted, the latest master is cloned. To get a specific release version run
git checkout <tagname>
from the SRT_ROOT
folder.
git checkout v1.4.1
cmake ../ -G"Visual Studio 16 2019" -A x64
-DPTHREAD_INCLUDE_DIR="C:\pthread-win32\cinegy.pthreads-win64.2.9.1.17\sources"
-DPTHREAD_LIBRARY="C:\pthread-win32\cinegy.pthreads-win64.2.9.1.17\runtimes\win-x64\native\release\pthread_lib.lib"
Note! Additional options can be provided at this point.
In case vcpkg was used to build pthreads or OpenSSL, provide:
-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
In case NuGet was used to get pre-built pthreads libray, provide:
-DPTHREAD_INCLUDE_DIR
-DPTHREAD_LIBRARY
cmake --build .