Skip to content

Build Instructions

Maxim Sharabayko edited this page Jan 31, 2020 · 1 revision

In case you see potential improvements, please feel free to submit your suggestion or changes via GitHub issues.


Table of Contents:


Windows

Install Instructions

There are no pre-built windows versions available at the moment.


Build Instructions

Requirements

The following are the recommended requirements to build srt-xtransmit on Windows. Different versions of tools and libraries can be used, but they are not confirmed to work.

  • cmake v3.10 and higher (cross-platform family of tools build software)
  • git client (source code management)
  • Visual Studio 2019 (compiler and linker)
  • One of the following Crypto libraries (for cryptographic functionality of SRT):
    • OpenSSL
    • LibreSSL
    • MbedTLS
  • pthreads (threading library used by SRT)

1. Cloning the Source Code

The source code of srt-xtransmit uses several libraries as git submodules. The following steps will get all the required sources.

git clone https://github.com/maxsharabayko/srt-xtransmit.git srt-xtransmit
cd srt-xtransmit
git submodule init
git submodule update

The current working directory will further be referenced as XTRANSMIT_ROOT.

set XTRANSMIT_ROOT=%cd%

Note! The above can be done in a single step by passing --recurse-submodules to the git clone command.

git clone https://github.com/maxsharabayko/srt-xtransmit.git srt-xtransmit --recurse-submodules

Note! If you have already cloned the project and forgot --recurse-submodules, you can combine the git submodule init and git submodule update steps by running git submodule update --init. To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive.

Note! Switching SRT version.

Before building the project with cmake, checkout the desired SRT library version.

After git submodule update --init go to submodule/srt and checkout the required version, e.g. v1.3.4

cd submodule/srt
git checkout v1.3.4

2. Preparing Dependencies

One of the following steps can be used to prepare the required dependencies.

Instructions in Section 2.1 cover all the required dependencies: openssl library and pthreads library. You can proceed directly to Section 3 afterwards.

Sections 2.2 - 2.4 are mutually exclusive: pick only one of them depending on the crypto library you would like to use. The proceed to pthreads installation instructions in Section 2.5 (or in Section 2.1).

2.1. Building Dependencies with vcpkg

vcpkg is a C++ library manager for Windows, Linux and MacOS. Consider its prerequisites before going further.

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%

Then build openssl and pthreads libraries using x64 toolset:

vcpkg install pthreads --triplet x64-windows
vcpkg install openssl --triplet x64-windows

The next step is to integrate vcpkg with the build system, so that CMake can locate openssl and pthreads libraries.

vcpkg integrate install

Now go to the srt-xtransmit cloned folder XTRANSMIT_ROOT and run cmake to generate build configuration files.

cd %XTRANSMIT_ROOT%
md _build && cd _build
cmake ../ -G "Visual Studio 16 2019" -A x64
          -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\scripts\buildsystems\vcpkg.cmake

where XTRANSMIT_ROOT and VCPKG_ROOT were defined above.

Go to Section 3.

2.2. Installing OpenSSL

2.2.1. Using Installer

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 be changed and older versions may become no longer available. In that case found 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.2.2 Build OpenSSL from Sources.

2.2.2. Build from Sources

Download and compile the sources from the website. The instructions for compiling on Windows can be found here: link.

Note! ActivePerl and nasm are required to build OpenSSL.

2.3. Install MbedTLS

MbedTLS source code can be downloaded from here: link.

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.

2.4. Install LibreSSL

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 have been no new Windows builds since 2.6.0, you must build a new version yourself. 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.

2.5. Build pthreads from Sources

Either pthreads4w or pthread-win32 can be used. The latter one does not get updated, so consider using pthreads4w.

2.5.1. Build pthreads4w

Download the source code from SourceForge (link) and follow build instruction.

2.5.2. Build pthread-win32

Compile and install pthread-win32 for Windows from GitHub: link.

  1. Using Visual Studio 2013, open the project file pthread_lib.2013.vcxproj
  2. Select configuration: Release and x64.
  3. Make sure that the pthread_lib project will be built.
  4. After building, find the pthread_lib.lib file (directory is usually bin\x64_MSVC2013.Release). Copy this file to C:\pthread-win32\lib (or whatever other location you configured in variables).
  5. Copy include files to C:\pthread-win32\include (pthread.h, sched.h, and semaphore.h are in the toplevel directory. There are no meaningful subdirs here). Note that win## is part of the project name. It will become win32 or win64 depending on the selection.

2.6. Generate Build Files Using CMake

TODO:

  • Add cmake instruction for cases 2.2-2.5.

2.7. Getting pthreads Using NuGet

NuGet package manager can be used to get a prebuilt version of pthreads library for Windows. Please note that OpenSSL library has to be installed separately in this case, e.g. using instructions from section "2.2. Installing OpenSSL Using Installer".

To install the prebuild version of pthreads for Windows, download nuget CLI to the _build folder: %XTRANSMIT_ROOT%\_build.

Then 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

Assuming OpenSSL is installed as suggested in the Section 2.2, run cmake to generate build configuration files:

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"

Got to Section 3.

3. Building the Project

To build the project go to %XTRANSMIT_ROOT%\_build and run:

cmake --build ./ --config Release

Alternatively Visual Studio IDE can be used by opening the generated solution file SRT-XTRANSMIT.sln in the _build folder.