最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

Windows下编译SRT

业界 admin 5浏览 0评论

参考:https://github/Haivision/srt/blob/master/docs/build/build-win.md


文章目录

  • 一、精简步骤
    • 1、准备cmake工具,并添加到系统环境变量中
    • 2、准备vs2019社区版开发环境
    • 3、克隆srt源码
    • 4、构建、编译多线程C++11标准库非加密的srt.dll
    • 5、成品
  • 二、详细步骤
  • Building SRT for Windows(构建Windows版本的SRT)
    • 1. Prerequisites(开发环境)
      • 1.1. Build Tool Dependencies(构建工具)
      • 1.2. External Library Dependencies(外部库的依赖关系)
        • 1.2.1. Cryptographic Library(加密库)
        • 1.2.2. Threading Library(线程库)
      • 1.3. Package Managers(软件包管理器)
        • 1.3.1. VCpkg Packet Manager (optional) VCpkg包管理器(可选)
        • 1.3.2. NuGet Manager (optional) NuGet管理(可选)
    • 2. Preparing Dependencies(准备依赖关系)
      • 2.1 Cryptographic Library(加密库)
        • 2.1.1. Install OpenSSL(安装OpenSSL)
          • 2.1.1.1. Using vcpkg(使用 vcpkg)
          • 2.1.1.2. Using Installer (Windows) 使用安装程序
          • 2.1.1.3. Build from Sources(从源码构建)
        • 2.1.2. Install MbedTLS(安装MbedTLS)
        • 2.1.3. Install LibreSSL(安装LibreSSL)
      • 2.2. Threading Library(线程库)
        • 2.2.1. Using C++11 Threading(采用C++线程库)
        • 2.2.2. Building PThreads(构建PThreads)
          • 2.2.2.1. Using vcpkg(使用vcpkg)
          • 2.2.2.2. Using NuGet(使用NuGet)
          • 2.2.2.3. Build pthreads4w from Sources(从源码构建pthreads4w)
          • 2.2.2.4. Build pthread-win32 from Sources(从源码构建pthread-win32)
    • 3. Building SRT(构建SRT)
      • 3.1. Cloning the Source Code(克隆源代码)
      • 3.2. Generate Build Files(生成构建文件)
      • 3.3. Build SRT(构建SRT)


一、精简步骤

1、准备cmake工具,并添加到系统环境变量中

https://cmake/download

2、准备vs2019社区版开发环境

3、克隆srt源码

git clone https://github/Haivision/srt.git

4、构建、编译多线程C++11标准库非加密的srt.dll

cd srt
mkdir build
cmake ../ -G"Visual Studio 16 2019" -A x64 -DENABLE_ENCRYPTION=OFF -DENABLE_STDCXX_SYNC=ON
cmake --build .

5、成品

二、详细步骤

Building SRT for Windows(构建Windows版本的SRT)

1. Prerequisites(开发环境)

1.1. Build Tool Dependencies(构建工具)

The following are the recommended prerequisites to build srt on Windows.

以下是在Windows上构建 srt的前提。

  • 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)

1.2. External Library Dependencies(外部库的依赖关系)

1.2.1. Cryptographic Library(加密库)

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.

SRT有一个外部依赖于加密库。 这个依赖可以通过-DENABLE_ENCRYPTION=OFF 的CMake构建选项来禁用。 禁用加密后,SRT将无法建立安全连接,只能使用未加密的模式。

With the enabled SRT encryption,one of the following Crypto libraries is required:

启用SRT加密后,需要以下加密库之一:

  • OpenSSL (default默认)
  • LibreSSL
  • MbedTLS
1.2.2. Threading Library(线程库)

SRT as of v1.4.2 supports two threading libraries:

从v1.4.2开始,SRT支持两个线程库:

  • Standard C++ thread library available in C++11 (default on Windows)
  • C++11提供了标准的C++线程库 (Windows默认)
  • pthreads (not recommended on Windows)
  • pthreads (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.

pthreads库在所有基于posix的系统上都是开箱即用的。 在Windows上,它可以作为第三方库提供(见下文)。 但是,推荐在Windows上使用c++标准线程库。

1.3. Package Managers(软件包管理器)

1.3.1. VCpkg Packet Manager (optional) VCpkg包管理器(可选)

Can be used to:(可用于:)

  • build OpenSSL library (dependency of SRT).
  • 构建OpenSSL库(SRT的依赖)
  • build pthreads library (dependency of SRT).
  • 构建pthreads库(SRT的依赖)

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

vcpkg 是一个c++库管理器,适用于Windows, Linux和MacOS。在继续之前考虑它的先决条件。

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.

vcpkg 库管理器已经为OpenSSLpthreads库预先配置了构建过程。它们可以很容易地构建,并进一步用作SRT库的依赖项。

Note! vcpkg does not support LibreSSL or MbedTLS libraries.

请注意! vcpkg 不支持 LibreSSL or MbedTLS 库.

Clone vcpkg using git, and build it.

用git克隆vcpkg,并编译

git clone https://github/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

The current working directory will further be referenced as VCPKG_ROOT.

当前工作目录将被进一步引用为 VCPKG_ROOT.

set VCPKG_ROOT=%cd%
1.3.2. NuGet Manager (optional) NuGet管理(可选)

NuGet package manager can be used to get a prebuilt version of pthreads library for Windows.

NuGet包管理器可以用来获取Windows版本的 pthreads 库的预构建版本。

Download nuget CLI to the desired folder.

下载 nuget CLI 到目标文件夹。

The directory with NuGet will further be referenced as NUGET_ROOT.

带有 NuGet 的目录将被进一步引用为 NUGET_ROOT.

set NUGET_ROOT=%cd%

2. Preparing Dependencies(准备依赖关系)

2.1 Cryptographic Library(加密库)

To build SRT with support for encryption,one of the following Crypto libraries is required:

要构建支持加密的SRT,需要下列加密库中的一个:

  • OpenSSL (recommended被推荐)
  • LibreSSL
  • MbedTLS
2.1.1. Install OpenSSL(安装OpenSSL)
2.1.1.1. Using vcpkg(使用 vcpkg)

Note! The vcpkg working directory is referenced as VCPKG_ROOT.

请注意! VCPKG_ROOT 设置为vcpkg 的工作目录

Building openssl library using x64 toolset:

使用x64工具集构建openssl库:

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 集成到构建系统中,这样 CMake 就可以找到 openssl 库。

vcpkg integrate install

CMake will be able to find openssl given the following option is provided:

如果提供以下选项,CMake将能够找到openssl:

-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
2.1.1.2. Using Installer (Windows) 使用安装程序

The 64-bit OpenSSL package for Windows can be downloaded using
the following link: Win64OpenSSL_Light-1_1_1c.

Windows操作系统的64位OpenSSL包可以通过以下路径下载:: 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.

请注意! 最后一个字母或版本号可能会改变,旧版本可能不再可用。 在这种情况下,请在这里找到适当的安装程序: 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.

下载并运行安装程序。 这个库应该安装在C:\Program Files\OpenSSL-Win64中。 将此路径添加到用户或系统的环境变量 PATH中。

It’s expected to be installed in C:\OpenSSL-Win64.

它应该安装在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.

请注意,这个版本很可能是为Visual Studio 2013编译的。 其他版本请参考章节中的说明 2.1.1.3 Build from Sources.

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.

从OpenSSL网站下载并编译源代码。 在Windows上编译的说明可以在这里找到:link。

Note! ActivePerl and nasm are required to build OpenSSL.

请注意! 构建OpenSSL需要ActivePerlnasm

2.1.2. Install MbedTLS(安装MbedTLS)

MbedTLS source code can be downloaded from the website.

MbedTLS的源代码可以从这个网站下载。

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.

MbedTLS带有cmake构建系统支持。 使用CMAKE_INSTALL_PREFIX变量指定包含MbedTLS头文件和库的目录。 请注意,将MbedTLS构建为DLL在2.16.3版本中已被打破。 你必须静态链接它。

2.1.3. Install LibreSSL(安装LibreSSL)

LibreSSL has header files that are compatible with OpenSSL,CMake can use it like OpenSSL with little configuration.

LibreSSL有与OpenSSL兼容的头文件,CMake可以像使用OpenSSL一样使用它,只需要很少的配置。

The source code and binaries can be downloaded from here: link.

源代码和二进制文件可以从这里下载: 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.

由于没有最近的Windows版本,惟一的选择就是从源代码构建一个新版本。 LibreSSL提供了CMake构建系统支持。 使用CMAKE_INSTALL_PREFIX变量来指定将包含LibreSSL头文件和库的目录。

2.2. Threading Library(线程库)

SRT can use one of these two threading libraries:

SRT可以使用这两个线程库中的一个:

  • C++11 threads (SRT v1.4.2 and above) - recommended, default since SRT v1.4.4;
  • pthreads (not recommended on Windows).
2.2.1. Using C++11 Threading(采用C++线程库)

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.

为了能够使用标准的c++线程库(从c++ 11开始可用),指定CMake选项 -DENABLE_STDCXX_SYNC=ON。 这样,线程库也不会有外部依赖。 否则,需要外部PThreads for Windows线程库。

2.2.2. Building PThreads(构建PThreads)

It is not recommended to use pthreads port on Windows. Consider using C++11 instead

不建议在Windows上使用pthreads端口。 考虑使用C++11代替

2.2.2.1. Using vcpkg(使用vcpkg)

Note! The vcpkg working directory is referenced as VCPKG_ROOT.

请注意! VCPKG_ROOT 设置为vcpkg 的工作目录

Build the pthreads library using the x64 toolset:

使用 x64 工具集构建pthreads 库:

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与构建系统集成,以便CMake可以定位pthreads库。

vcpkg integrate install

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

现在转到srt-xtransmit克隆文件夹XTRANSMIT_ROOT并运行cmake来生成构建配置文件。

CMake will be able to find openssl given the following option is provided:

如果提供以下选项,CMake将能够找到openssl:

-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
2.2.2.2. Using NuGet(使用NuGet)

This step assumes the NuGet is available from the NUGET_ROOT folder(refer to 1.3.2. NuGet Manager (optional)).

这一步假设NuGet可以从NUGET_ROOT文件夹中获得(参见1.3.2. NuGet Manager (optional)](#132-nuget-manager-optional)).

Run nuget to install pthreads to the specified path.

运行nugetpthreads安装到指定的路径。

In the example below the library will be installed in C:\pthread-win32.

在下面的例子中,库将被安装在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.

在这个步骤中必须提供两个CMake选项 3.2. 生成构建文件.

-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"
2.2.2.3. Build pthreads4w from Sources(从源码构建pthreads4w)

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

从SourceForge(链接)下载源代码,并遵循构建说明。

2.2.2.4. Build pthread-win32 from Sources(从源码构建pthread-win32)

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

从GitHub编译并安装Windows版本的pthread-win32: 链接.

  1. Using Visual Studio 2013, open the project file pthread_lib.2013.vcxproj
  1. (使用Visual Studio 2013,打开项目文件pthread_lib.2013.vcxproj
  1. Select configuration: Release and x64.
  1. (选择配置:Release and x64
  1. Make sure that the pthread_lib project will be built.
  1. (确保将构建 pthread_lib项目。)
  1. 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).
  1. 在构建之后,找到pthread_lib.lib文件(目录通常是bin\x64_MSVC2013.Release) 复制此文件到C:\pthread-win32\lib(或任何其他你配置在变量中的位置)。
  1. 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.
  1. 将包含文件拷贝到C:\pthread-win32\include (’ pthread.h, sched.h,和semaphore.h在顶层目录。 这里没有有意义的子目录)。 注意,win##是项目名称的一部分。 根据选择,它将变成win32win64

3. Building SRT(构建SRT)

3.1. Cloning the Source Code(克隆源代码)

Retrieve the SRT source code from GitHub using a git client.

使用git客户端从GitHub获取SRT源代码。

git clone --branch <tag_name> https://github/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,

其中--branch <tag_name>可用于定义SRT的特定发布版本,

e.g. --branch v1.4.1.

例如.--branch v1.4.1.

Note! The current working directory will further be referenced as SRT_ROOT.

**请注意!**当前工作目录将进一步被引用为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.

如果省略了--branch <tag_name>,则克隆最新的主节点。 从SRT_ROOT文件夹来运行特定的发布版本git checkout <tagname>

git checkout v1.4.1

3.2. Generate Build 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"

Note! Additional options can be provided at this point.

请注意! 此时可提供其他选项。

In case vcpkg was used to build pthreads or OpenSSL, provide:

如果使用vcpkg来构建pthreads或OpenSSL,请提供:

  • -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake

In case NuGet was used to get pre-built pthreads libray, provide:

如果使用NuGet来获取预构建的pthreads库,请提供:

  • -DPTHREAD_INCLUDE_DIR
  • -DPTHREAD_LIBRARY

3.3. Build SRT(构建SRT)

cmake --build .

参考:https://github/Haivision/srt/blob/master/docs/build/build-win.md


文章目录

  • 一、精简步骤
    • 1、准备cmake工具,并添加到系统环境变量中
    • 2、准备vs2019社区版开发环境
    • 3、克隆srt源码
    • 4、构建、编译多线程C++11标准库非加密的srt.dll
    • 5、成品
  • 二、详细步骤
  • Building SRT for Windows(构建Windows版本的SRT)
    • 1. Prerequisites(开发环境)
      • 1.1. Build Tool Dependencies(构建工具)
      • 1.2. External Library Dependencies(外部库的依赖关系)
        • 1.2.1. Cryptographic Library(加密库)
        • 1.2.2. Threading Library(线程库)
      • 1.3. Package Managers(软件包管理器)
        • 1.3.1. VCpkg Packet Manager (optional) VCpkg包管理器(可选)
        • 1.3.2. NuGet Manager (optional) NuGet管理(可选)
    • 2. Preparing Dependencies(准备依赖关系)
      • 2.1 Cryptographic Library(加密库)
        • 2.1.1. Install OpenSSL(安装OpenSSL)
          • 2.1.1.1. Using vcpkg(使用 vcpkg)
          • 2.1.1.2. Using Installer (Windows) 使用安装程序
          • 2.1.1.3. Build from Sources(从源码构建)
        • 2.1.2. Install MbedTLS(安装MbedTLS)
        • 2.1.3. Install LibreSSL(安装LibreSSL)
      • 2.2. Threading Library(线程库)
        • 2.2.1. Using C++11 Threading(采用C++线程库)
        • 2.2.2. Building PThreads(构建PThreads)
          • 2.2.2.1. Using vcpkg(使用vcpkg)
          • 2.2.2.2. Using NuGet(使用NuGet)
          • 2.2.2.3. Build pthreads4w from Sources(从源码构建pthreads4w)
          • 2.2.2.4. Build pthread-win32 from Sources(从源码构建pthread-win32)
    • 3. Building SRT(构建SRT)
      • 3.1. Cloning the Source Code(克隆源代码)
      • 3.2. Generate Build Files(生成构建文件)
      • 3.3. Build SRT(构建SRT)


一、精简步骤

1、准备cmake工具,并添加到系统环境变量中

https://cmake/download

2、准备vs2019社区版开发环境

3、克隆srt源码

git clone https://github/Haivision/srt.git

4、构建、编译多线程C++11标准库非加密的srt.dll

cd srt
mkdir build
cmake ../ -G"Visual Studio 16 2019" -A x64 -DENABLE_ENCRYPTION=OFF -DENABLE_STDCXX_SYNC=ON
cmake --build .

5、成品

二、详细步骤

Building SRT for Windows(构建Windows版本的SRT)

1. Prerequisites(开发环境)

1.1. Build Tool Dependencies(构建工具)

The following are the recommended prerequisites to build srt on Windows.

以下是在Windows上构建 srt的前提。

  • 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)

1.2. External Library Dependencies(外部库的依赖关系)

1.2.1. Cryptographic Library(加密库)

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.

SRT有一个外部依赖于加密库。 这个依赖可以通过-DENABLE_ENCRYPTION=OFF 的CMake构建选项来禁用。 禁用加密后,SRT将无法建立安全连接,只能使用未加密的模式。

With the enabled SRT encryption,one of the following Crypto libraries is required:

启用SRT加密后,需要以下加密库之一:

  • OpenSSL (default默认)
  • LibreSSL
  • MbedTLS
1.2.2. Threading Library(线程库)

SRT as of v1.4.2 supports two threading libraries:

从v1.4.2开始,SRT支持两个线程库:

  • Standard C++ thread library available in C++11 (default on Windows)
  • C++11提供了标准的C++线程库 (Windows默认)
  • pthreads (not recommended on Windows)
  • pthreads (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.

pthreads库在所有基于posix的系统上都是开箱即用的。 在Windows上,它可以作为第三方库提供(见下文)。 但是,推荐在Windows上使用c++标准线程库。

1.3. Package Managers(软件包管理器)

1.3.1. VCpkg Packet Manager (optional) VCpkg包管理器(可选)

Can be used to:(可用于:)

  • build OpenSSL library (dependency of SRT).
  • 构建OpenSSL库(SRT的依赖)
  • build pthreads library (dependency of SRT).
  • 构建pthreads库(SRT的依赖)

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

vcpkg 是一个c++库管理器,适用于Windows, Linux和MacOS。在继续之前考虑它的先决条件。

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.

vcpkg 库管理器已经为OpenSSLpthreads库预先配置了构建过程。它们可以很容易地构建,并进一步用作SRT库的依赖项。

Note! vcpkg does not support LibreSSL or MbedTLS libraries.

请注意! vcpkg 不支持 LibreSSL or MbedTLS 库.

Clone vcpkg using git, and build it.

用git克隆vcpkg,并编译

git clone https://github/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

The current working directory will further be referenced as VCPKG_ROOT.

当前工作目录将被进一步引用为 VCPKG_ROOT.

set VCPKG_ROOT=%cd%
1.3.2. NuGet Manager (optional) NuGet管理(可选)

NuGet package manager can be used to get a prebuilt version of pthreads library for Windows.

NuGet包管理器可以用来获取Windows版本的 pthreads 库的预构建版本。

Download nuget CLI to the desired folder.

下载 nuget CLI 到目标文件夹。

The directory with NuGet will further be referenced as NUGET_ROOT.

带有 NuGet 的目录将被进一步引用为 NUGET_ROOT.

set NUGET_ROOT=%cd%

2. Preparing Dependencies(准备依赖关系)

2.1 Cryptographic Library(加密库)

To build SRT with support for encryption,one of the following Crypto libraries is required:

要构建支持加密的SRT,需要下列加密库中的一个:

  • OpenSSL (recommended被推荐)
  • LibreSSL
  • MbedTLS
2.1.1. Install OpenSSL(安装OpenSSL)
2.1.1.1. Using vcpkg(使用 vcpkg)

Note! The vcpkg working directory is referenced as VCPKG_ROOT.

请注意! VCPKG_ROOT 设置为vcpkg 的工作目录

Building openssl library using x64 toolset:

使用x64工具集构建openssl库:

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 集成到构建系统中,这样 CMake 就可以找到 openssl 库。

vcpkg integrate install

CMake will be able to find openssl given the following option is provided:

如果提供以下选项,CMake将能够找到openssl:

-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
2.1.1.2. Using Installer (Windows) 使用安装程序

The 64-bit OpenSSL package for Windows can be downloaded using
the following link: Win64OpenSSL_Light-1_1_1c.

Windows操作系统的64位OpenSSL包可以通过以下路径下载:: 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.

请注意! 最后一个字母或版本号可能会改变,旧版本可能不再可用。 在这种情况下,请在这里找到适当的安装程序: 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.

下载并运行安装程序。 这个库应该安装在C:\Program Files\OpenSSL-Win64中。 将此路径添加到用户或系统的环境变量 PATH中。

It’s expected to be installed in C:\OpenSSL-Win64.

它应该安装在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.

请注意,这个版本很可能是为Visual Studio 2013编译的。 其他版本请参考章节中的说明 2.1.1.3 Build from Sources.

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.

从OpenSSL网站下载并编译源代码。 在Windows上编译的说明可以在这里找到:link。

Note! ActivePerl and nasm are required to build OpenSSL.

请注意! 构建OpenSSL需要ActivePerlnasm

2.1.2. Install MbedTLS(安装MbedTLS)

MbedTLS source code can be downloaded from the website.

MbedTLS的源代码可以从这个网站下载。

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.

MbedTLS带有cmake构建系统支持。 使用CMAKE_INSTALL_PREFIX变量指定包含MbedTLS头文件和库的目录。 请注意,将MbedTLS构建为DLL在2.16.3版本中已被打破。 你必须静态链接它。

2.1.3. Install LibreSSL(安装LibreSSL)

LibreSSL has header files that are compatible with OpenSSL,CMake can use it like OpenSSL with little configuration.

LibreSSL有与OpenSSL兼容的头文件,CMake可以像使用OpenSSL一样使用它,只需要很少的配置。

The source code and binaries can be downloaded from here: link.

源代码和二进制文件可以从这里下载: 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.

由于没有最近的Windows版本,惟一的选择就是从源代码构建一个新版本。 LibreSSL提供了CMake构建系统支持。 使用CMAKE_INSTALL_PREFIX变量来指定将包含LibreSSL头文件和库的目录。

2.2. Threading Library(线程库)

SRT can use one of these two threading libraries:

SRT可以使用这两个线程库中的一个:

  • C++11 threads (SRT v1.4.2 and above) - recommended, default since SRT v1.4.4;
  • pthreads (not recommended on Windows).
2.2.1. Using C++11 Threading(采用C++线程库)

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.

为了能够使用标准的c++线程库(从c++ 11开始可用),指定CMake选项 -DENABLE_STDCXX_SYNC=ON。 这样,线程库也不会有外部依赖。 否则,需要外部PThreads for Windows线程库。

2.2.2. Building PThreads(构建PThreads)

It is not recommended to use pthreads port on Windows. Consider using C++11 instead

不建议在Windows上使用pthreads端口。 考虑使用C++11代替

2.2.2.1. Using vcpkg(使用vcpkg)

Note! The vcpkg working directory is referenced as VCPKG_ROOT.

请注意! VCPKG_ROOT 设置为vcpkg 的工作目录

Build the pthreads library using the x64 toolset:

使用 x64 工具集构建pthreads 库:

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与构建系统集成,以便CMake可以定位pthreads库。

vcpkg integrate install

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

现在转到srt-xtransmit克隆文件夹XTRANSMIT_ROOT并运行cmake来生成构建配置文件。

CMake will be able to find openssl given the following option is provided:

如果提供以下选项,CMake将能够找到openssl:

-DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake
2.2.2.2. Using NuGet(使用NuGet)

This step assumes the NuGet is available from the NUGET_ROOT folder(refer to 1.3.2. NuGet Manager (optional)).

这一步假设NuGet可以从NUGET_ROOT文件夹中获得(参见1.3.2. NuGet Manager (optional)](#132-nuget-manager-optional)).

Run nuget to install pthreads to the specified path.

运行nugetpthreads安装到指定的路径。

In the example below the library will be installed in C:\pthread-win32.

在下面的例子中,库将被安装在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.

在这个步骤中必须提供两个CMake选项 3.2. 生成构建文件.

-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"
2.2.2.3. Build pthreads4w from Sources(从源码构建pthreads4w)

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

从SourceForge(链接)下载源代码,并遵循构建说明。

2.2.2.4. Build pthread-win32 from Sources(从源码构建pthread-win32)

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

从GitHub编译并安装Windows版本的pthread-win32: 链接.

  1. Using Visual Studio 2013, open the project file pthread_lib.2013.vcxproj
  1. (使用Visual Studio 2013,打开项目文件pthread_lib.2013.vcxproj
  1. Select configuration: Release and x64.
  1. (选择配置:Release and x64
  1. Make sure that the pthread_lib project will be built.
  1. (确保将构建 pthread_lib项目。)
  1. 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).
  1. 在构建之后,找到pthread_lib.lib文件(目录通常是bin\x64_MSVC2013.Release) 复制此文件到C:\pthread-win32\lib(或任何其他你配置在变量中的位置)。
  1. 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.
  1. 将包含文件拷贝到C:\pthread-win32\include (’ pthread.h, sched.h,和semaphore.h在顶层目录。 这里没有有意义的子目录)。 注意,win##是项目名称的一部分。 根据选择,它将变成win32win64

3. Building SRT(构建SRT)

3.1. Cloning the Source Code(克隆源代码)

Retrieve the SRT source code from GitHub using a git client.

使用git客户端从GitHub获取SRT源代码。

git clone --branch <tag_name> https://github/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,

其中--branch <tag_name>可用于定义SRT的特定发布版本,

e.g. --branch v1.4.1.

例如.--branch v1.4.1.

Note! The current working directory will further be referenced as SRT_ROOT.

**请注意!**当前工作目录将进一步被引用为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.

如果省略了--branch <tag_name>,则克隆最新的主节点。 从SRT_ROOT文件夹来运行特定的发布版本git checkout <tagname>

git checkout v1.4.1

3.2. Generate Build 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"

Note! Additional options can be provided at this point.

请注意! 此时可提供其他选项。

In case vcpkg was used to build pthreads or OpenSSL, provide:

如果使用vcpkg来构建pthreads或OpenSSL,请提供:

  • -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake

In case NuGet was used to get pre-built pthreads libray, provide:

如果使用NuGet来获取预构建的pthreads库,请提供:

  • -DPTHREAD_INCLUDE_DIR
  • -DPTHREAD_LIBRARY

3.3. Build SRT(构建SRT)

cmake --build .
发布评论

评论列表 (0)

  1. 暂无评论