Building Instructions for Windows
Building Instructions for Windows
Below are the instructions for building ZLMediaKit on Windows using scoop + vcpkg.
scoop: A package installation manager for Windows command-line.vcpkg: A C++ library manager initiated by Microsoft, which includes many commonly used open-source libraries.
Since these tools can be used from the command line, they enable convenient automation and integration. We recommend giving them a try.
Please note that the following steps have only been tested on Windows 10 and may not work on other Windows versions.
Unless specified otherwise, all operations should be performed in PowerShell command line.
Installing Build Dependencies using scoop and vcpkg
Download and Install scoop, and use scoop to install dependency tools
The following steps are for installing the dependency tools cmake and ninja (optional but recommended) using scoop. If you already have them installed, you can skip these steps.
For detailed instructions, please refer to the official scoop documentation. Below are the summarized steps:
Set the environment variable
SCOOPto configure the download and installation directory forscoop(including the managed software packages). Run the following command:$env:SCOOP = 'C:\work\develop\scoop'Allow the execution of PowerShell scripts for the current user by running the following command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserInstall
scoopby running the following command:iwr -useb get.scoop.sh | iexAdd the
extrassoftware repository toscoopby running the following command:scoop bucket add extrasInstall
cmakeandninjaby running the following command:scoop install cmake ninja
For convenience, you should set C:\work\develop\scoop as the value for the SCOOP environment variable and append C:\work\develop\scoop\shims to the PATH environment variable. You can search for the appropriate method to do this.
Download and Configure vcpkg, and use vcpkg to install library dependencies
The following steps are for installing the required library dependencies, including openssl and libsrtp. Other optional dependencies (e.g., ffmpeg) should also be installable but have not been tested yet.
For detailed usage of vcpkg, please refer to the official documentation.
Download
vcpkg, which includes various configuration scripts and build scripts for open-source libraries. Assume the download path isC:\work\develop. Run the following command:git clone https://github.com/microsoft/vcpkgDownload the precompiled
vcpkgpackage manager by running the following command:.\vcpkg\bootstrap-vcpkg.bat -disableMetricsBuild
opensslby running the following command:.\vcpkg\vcpkg.exe install --triplet=x64-windows-static opensslBuild
libsrtpwithENABLE_OPENSSLenabled. EditC:\work\develop\vcpkg\ports\libsrtp\portfile.cmakeand modifyvcpkg_configure_cmakeas follows:vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS -DENABLE_OPENSSL:BOOL=ON )Then, build
libsrtpby running the following command:.\vcpkg\vcpkg.exe install --triplet=x64-windows-static libsrtp
Building
Open the developer command prompt for vs2015/2017/2019 from the Start menu. If you can't find the 64-bit version based on powershell, you can use the cmd version first, and then switch to powershell by running the powershell command.
Build ZLMediaKit by running the following PowerShell commands:
mkdir build cd build $VCPKG_CMAKE = 'C:\work\develop\vcpkg\scripts\buildsystems\vcpkg.cmake' $VCPKG_INSTALL_PATH = 'C:\work\develop\vcpkg\installed\x64-windows-static' $CMAKE_OPTIONS = @( "-GCodeBlocks - Ninja" "-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo" "-DCMAKE_C_COMPILER:STRING=cl.exe" "-DCMAKE_CXX_COMPILER:STRING=cl.exe" "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=$VCPKG_CMAKE" "-DCMAKE_PREFIX_PATH:FILEPATH=$VCPKG_INSTALL_PATH" "-DVCPKG_TARGET_TRIPLET:STRING=x86-windows-static" "-DENABLE_WEBRTC:BOOL=ON" ) cmake .. @CMAKE_OPTIONS cmake --build . --target all
To compile a 64-bit program and link openssl, you also need to link Crypt32.lib and ws2_32.lib. Normally, when executing cmake .. @CMAKE_OPTIONS, you should see similar output like this:
found library:C:/work/develop/vcpkg/installed/x64-windows-static/lib/libssl.lib;C:/work/develop/vcpkg/installed/x64-windows-static/lib/libcrypto.lib;Crypt32.lib;ws2_32.lib,ENABLE_OPENSSL defined
If Crypt32.lib and ws2_32.lib are not present, you can manually modify the CMakeLists.txt file to resolve the issue (search for OPENSSL_LIBRARIES to find the corresponding location).
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES} Crypt32.lib ws2_32.lib)