环境说明

ZLMediaKit编译需要的软件

visual studio 2022
cmake 3.29.0-rc2
OpenSSL 1.1.1w(不想踩坑的话安装这个版本)
libsrtp 2.6.0

ZLMediaKit编译后运行需要

libsrtp 编译后且配置环境变量
ZLMediaKit 编译后文件

visual studio

Snipaste_2024-02-28_17-33-25

Snipaste_2024-02-28_17-34-19

Snipaste_2024-02-28_17-35-53

cmake

visual stuido 20222,自带cmake

cmake可以到这两个地方下载:
下载1

下载2

Snipaste_2024-02-28_09-48-44

Snipaste_2024-02-27_13-02-04

Snipaste_2024-02-28_09-49-07

Snipaste_2024-02-28_09-49-24

Snipaste_2024-02-29_15-12-23

Snipaste_2024-02-29_15-12-30

测试是否成功

C:\Users\XXX>cmake
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Run 'cmake --help' for more information.

OpenSSL

可以到
OpenSSL
安装window编译版本, 记得
要下载是exe或msi文件,不要light的文件!!!!!

Snipaste_2024-02-27_13-02-04

按步骤安装,安装地址为:C:\Program Files\OpenSSL-Win64

Snipaste_2024-02-27_15-49-25

配置环境变量

一定要配置正确!!!

Snipaste_2024-02-27_09-46-14

测试

C:\Users\XXX>openssl -v
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)

可以不重启电脑,但必须关闭已经打开cmd窗口,否则会显示'openssl' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

libsrtp

libsrtp
下载后解压,解压路径地址为: D:\XXX\soft\libsrtp-2.6.0

有两种编译方式:

第一种:
visual stuido

cmake
结合使用

  1. 首先在D:\XXX\soft\libsrtp-2.6.0\libsrtp-2.6.0新建build和install两个文件夹

  2. 打开cmake软件
    Snipaste_2024-02-29_14-26-41

  3. 完成后出现红色配置,勾选上BUILD_SHARED_LIBS、ENABLE_OPENSSL、以及CMAKE_INSTALL_PREFIX的路径,然后点生成。
    注意这里有个问题
    Could NOT find OpenSSL

    Snipaste_2024-02-29_14-29-54

  4. 如果3顺利的话,完成后的结果(
    换回1.1.1的测试结果
    ),然后点open project

    Snipaste_2024-02-29_16-54-09

  5. 会打开vs

    Snipaste_2024-02-29_17-13-25

  6. 生成后会出现一些错误(但无影响)

    Snipaste_2024-02-29_17-14-51

  7. install文件夹生成的目录

    install目录│文件列表:
     ├ include
     │  └ srtp2
     │     │ auth.h
     │     │ cipher.h
     │     │ crypto_types.h
     │     └ srtp.h
     └ lib
        │ srtp2.dll
        │ srtp2.lib
        └ cmake
           └ libSRTP
              │ libSRTPConfig.cmake
              │ libSRTPConfigVersion.cmake
              │ libSRTPTargets-debug.cmake
              └ libSRTPTargets.cmake
    
  8. 配置环境变量到path

    D:\XXX\soft\libsrtp-2.6.0\libsrtp-2.6.0\install
    D:\XXX\soft\libsrtp-2.6.0\libsrtp-2.6.0\install\lib
    

编译ZLMediaKit

在使用VS打开ZLMediaKit项目时,如果未开启webrtc, 会出现

[CMake] -- set_file_group D:/XXX/project/ZLMediaKit/src 205
1> [CMake] -- srt 功能已开启
1> [CMake] CMake Warning at webrtc/CMakeLists.txt:28 (message):
1> [CMake]   srtp 未找到, WebRTC 相关功能打开失败

要开启webrtc,需要保证以下正确

  • 开启了webrtc

    Snipaste_2024-02-29_17-51-14

  • libsrtp编译正确且配置环境变量

开启成功的话, 会出现下面,然后安装ZLMediaKit

> [CMake] -- Enable wepoll
1> [CMake] -- set_file_group D:/XXX/project/ZLMediaKit/3rdpart/ZLToolKit/src 80
1> [CMake] -- set_file_group D:/XXX/project/ZLMediaKit/src 205
1> [CMake] -- srt 功能已开启
1> [CMake] -- found library: D:/XXX/soft/libsrtp-2.6.0/libsrtp-2.6.0/install/lib/srtp2.lib
1> [CMake] -- SCTP LIBRARIES: SCTP_LIBRARIES-NOTFOUND
1> [CMake] -- SCTP INCLUDE DIRS: SCTP_INCLUDE_DIRS-NOTFOUND
1> [CMake] -- WebRTC 功能已开启

image-20240229175901339

如果不行先把out和release文件夹删除,再重新打开vs,然后安装ZLMediaKit

Snipaste_2024-02-22_16-33-28

测试webrtc

打开编译目录,双击MediaServer.exe

image-20240306666664721947

先推流,用obs推流

Snipaste_2024-03-01_18-08-44

chrome浏览器打开

Snipaste_2024-03-01_18-05-58

点确定

Snipaste_2024-03-01_18-06-14

点开始

Snipaste_2024-03-01_18-09-45

问题

  • MediaServer.exe打开后,由于找不到 srtp2.dll,无法继续执行代码。重新安装程序可能会解决此问题

    检查srtp2.dll的环境变量是否正确,如:D:\XXX\soft\libsrtp-2.6.0\libsrtp-2.6.0\install\lib

    image-20240306666662912727

  • Could NOT find OpenSSL

CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
  OPENSSL_INCLUDE_DIR) (Required is at least version "1.1.0")		C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake	230		

开始以为是安装openssl步骤有问题,改为第一个选项,结果还是这样的接口

Snipaste_2024-02-28_10-13-28

然后看了报错

try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR

添加了环境变量

```
OPENSSL_ROOT_DIR	C:\Program Files\OpenSSL-Win64
OPENSSL_CRYPTO_LIBRARY	C:\Program Files\OpenSSL-Win64\lib
OPENSSL_INCLUDE_DIR	C:\Program Files\OpenSSL-Win64\include
```

Snipaste_2024-02-27_13-07-31

完成后重启,清除缓存生成依然没有效果

image-20240229160034606

解决方式

  • 换版本OpenSSL:
    Win64OpenSSL-1_1_1w.msi
    , 省很多事

    C:\Users\XXX>openssl version
    OpenSSL 1.1.1w  11 Sep 2023
    

    安装完成它的lib目录结构为:

    lib目录│文件列表:
     │ capi.lib
     │ dasync.lib
     │ ec_internal_test.lib
     │ libapps.lib
     │ libcrypto.def
     │ libcrypto.lib
     │ libcrypto_static.lib
     │ libssl.def
     │ libssl.lib
     │ libssl_static.lib
     │ libtestutil.lib
     │ openssl.lib
     │ ossltest.lib
     │ padlock.lib
     │ uitest.lib
     └ VC
        │ libcrypto64MD.lib
        │ libcrypto64MDd.lib
        │ libcrypto64MT.lib
        │ libcrypto64MTd.lib
        │ libssl64MD.lib
        │ libssl64MDd.lib
        │ libssl64MT.lib
        │ libssl64MTd.lib
        └ static
           │ libcrypto64MD.lib
           │ libcrypto64MDd.lib
           │ libcrypto64MT.lib
           │ libcrypto64MTd.lib
           │ libssl64MD.lib
           │ libssl64MDd.lib
           │ libssl64MT.lib
           └ libssl64MTd.lib
    

标签: none

添加新评论