新版 Mediasoup Windows 安装 编译
ps:视频测试demo,服务器配置很低,加载有点慢;需要有音视频设备,不然会报错。
关于官网文档
只测试了 Windows 。讲的不是很清楚,文档内容有缺失,通过查询 issues 、官网讨论论坛 和 自我尝试,还好最终编译运行成功了。
官网文档关键点
所有平台需要环境
- node version >= v12.0.0
- python version >= 3.6 with PIP
- GNU make
node 和 python 下载最新版本安装即可
node 没什么注意的
python 需要配置好环境变量并且删除系统自带的程序别名问题
系统用户环境变量里面有一个 %USERPROFILE%\AppData\Local\Microsoft\WindowsApps 这个文件夹里面有 python.exe 的快捷方式?会在安装 mediasoup 时导致 找不到 python pip 问题,进入 WindowsApps 文件夹把 python.exe python3.exe...删除了就可以。
GNU make 也通过文档提供的地址下载,安装,然后 添加路径(*:\MinGW\msys\1.0\bin)到环境变量,只是安装的时候需要注意,需要安装完 make 会依赖到的所有包。
最开始尝试只选中带 make 字段的包安装,在命令行 make -v 能正常弹出信息,但是尝试安装就会出错。具体是哪些不清楚...选了一大半,最后没问题了。
每次 MinGW Installer 下载安装包时,有可能会失败,失败了就可能导致最后 make 会出问题,所以需要关注一下,下载安装的log。
使用的 vscode 终端,make -v 可能没反应,就是有问题,用 cmd 命令行能弹出错误提示,总之, make 有问题就需要 通过 MinGW Installer 重新安装。
然后 Microsoft Visual Studio 可以在 官网下载
安装配置时必须选上 使用 C++ 的桌面开发
然后添加环境变量,包含三个关键程序的路径:cl.exe、vcvars64.bat、MSBuild.exe
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64
具体路径和 Microsoft Visual Studio 版本有关系,大概位置不变。
最后下载文档里面的证书 安装到计算机上,选择安装到 当前用户 和 本地计算机时,可以两个都装起...
编译时具体环境
安装流程 npm install mediasoup@3 --save
一直使用 vscode 终端 卡了一个错误好久
Directory does not contain a valid build tree: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker Build dir: H:\workspace\mediasoup-demo-3\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined meson.build:1:0: ERROR: Compiler cl can not compile programs.
Compiler cl can not compile programs ,让人崩溃。
这个有一个前提 需要提前运行一下 vcvars64 ,并且还有一点区别
默认新开终端是 PowerShell ,此时需要完整执行
cmd /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%/vcvars.txt" Get-Content "$env:temp\vcvars.txt" | Foreach-Object { if ($_ -match "^(.*?)=(.*)$") { Set-Content "env:\$($matches[1])" $matches[2] } }
然后再 npm install mediasoup
如果是选择 cmd ,则只需要 vcvars64 回车一下就好 。
此时应该都能进入正常流程,下载所需要的依赖、然后编译 mediasoup 的关键底层服务。
下载的时候很容易就会出错,导致安装失败
http.client.RemoteDisconnected: Remote end closed connection without response make: *** [setup] 错误 2
Remote end closed connection without response ,下载每个包都可能这样,如果网络没问题(vpn、番蔷),全部下载成功,即可进入编译,最后安装成功。
PowerShell
PS H:\workspace\edumeet-master\server> cmd /c "call `"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat`" && set > %temp%/vcvars.txt" ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.9.41 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' PS H:\workspace\edumeet-master\server> PS H:\workspace\edumeet-master\server> Get-Content "$env:temp\vcvars.txt" | Foreach-Object { >> if ($_ -match "^(.*?)=(.*)$") { >> Set-Content "env:\$($matches[1])" $matches[2] >> } >> } PS H:\workspace\edumeet-master\server> npm install mediasoup@3 --save > mediasoup@3.9.2 postinstall H:\workspace\edumeet-master\server\node_modules\mediasoup > node npm-scripts.js postinstall npm-scripts.js [INFO] running task "postinstall" npm-scripts.js [INFO] executing command: node npm-scripts.js worker:build npm-scripts.js [INFO] running task "worker:build" npm-scripts.js [INFO] executing command: make -C worker make: Entering directory `/h/workspace/edumeet-master/server/node_modules/mediasoup/worker' # Updated pip and setuptools are needed for meson # `--system` is not present everywhere and is only needed as workaround for # Debian-specific issue (copied from # https://github.com/gluster/gstatus/pull/33), fallback to command without # `--system` if the first one fails. python -m pip install --system --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ python -m pip install --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ echo "Installation failed, likely because PIP is unavailable, if you are on Debian/Ubuntu or derivative please install the python3-pip package" Usage: h:\Program Files\Python310\python.exe -m pip install [options] <requirement specifier> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] -r <requirements file> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <vcs project url> ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <local project path> ... h:\Program Files\Python310\python.exe -m pip install [options] <archive url/path> ... no such option: --system Collecting pip Using cached pip-21.3.1-py3-none-any.whl (1.7 MB) Collecting setuptools Using cached setuptools-59.2.0-py3-none-any.whl (952 kB) Installing collected packages: setuptools, pip Successfully installed pip-21.3.1 setuptools-59.2.0 # Install `meson` and `ninja` using `pip` into custom location, so we don't # depend on system-wide installation. python -m pip install --upgrade --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip meson ninja Collecting meson Using cached meson-0.60.2-py3-none-any.whl (838 kB) Collecting ninja Using cached ninja-1.10.2.3-py2.py3-none-win_amd64.whl (292 kB) Installing collected packages: ninja, meson Successfully installed meson-0.60.2 ninja-1.10.2.3 /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ --reconfigure \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release || \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release Directory does not contain a valid build tree: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker Build dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined C compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �Ż������� 19.16.27045 ��") C linker for the host machine: link link 14.16.27045.0 C++ compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �Ż������� 19.16.27045 ��") C++ linker for the host machine: link link 14.16.27045.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Downloading openssl source from https://www.openssl.org/source/openssl-1.1.1l.tar.gz Download size: 9834044 Downloading: .......... Downloading openssl patch from https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-2/get_patch Download size: 10613607 Downloading: .
Command Prompt
H:\workspace\edumeet-master\server>vcvars64 ********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.9.41 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' H:\workspace\edumeet-master\server>npm install mediasoup > mediasoup@3.9.2 postinstall H:\workspace\edumeet-master\server\node_modules\mediasoup > node npm-scripts.js postinstall npm-scripts.js [INFO] running task "postinstall" npm-scripts.js [INFO] executing command: node npm-scripts.js worker:build npm-scripts.js [INFO] running task "worker:build" npm-scripts.js [INFO] executing command: make -C worker make: Entering directory `/h/workspace/edumeet-master/server/node_modules/mediasoup/worker' # Updated pip and setuptools are needed for meson # `--system` is not present everywhere and is only needed as workaround for # Debian-specific issue (copied from # https://github.com/gluster/gstatus/pull/33), fallback to command without # `--system` if the first one fails. python -m pip install --system --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ python -m pip install --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip pip setuptools || \ echo "Installation failed, likely because PIP is unavailable, if you are on Debian/Ubuntu or derivative please install the python3-pip package" Usage: h:\Program Files\Python310\python.exe -m pip install [options] <requirement specifier> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] -r <requirements file> [package-index-options] ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <vcs project url> ... h:\Program Files\Python310\python.exe -m pip install [options] [-e] <local project path> ... h:\Program Files\Python310\python.exe -m pip install [options] <archive url/path> ... no such option: --system Collecting pip Using cached pip-21.3.1-py3-none-any.whl (1.7 MB) Collecting setuptools Using cached setuptools-59.2.0-py3-none-any.whl (952 kB) Installing collected packages: setuptools, pip Successfully installed pip-21.3.1 setuptools-59.2.0 # Install `meson` and `ninja` using `pip` into custom location, so we don't # depend on system-wide installation. python -m pip install --upgrade --target=/h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip meson ninja Collecting meson Using cached meson-0.60.2-py3-none-any.whl (838 kB) Collecting ninja Using cached ninja-1.10.2.3-py2.py3-none-win_amd64.whl (292 kB) Installing collected packages: ninja, meson Successfully installed meson-0.60.2 ninja-1.10.2.3 /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ --reconfigure \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release || \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/pip/bin/meson setup \ --buildtype release \ -Db_ndebug=true \ -Db_pie=true \ -Db_staticpic=true \ "" \ /h/workspace/edumeet-master/server/node_modules/mediasoup/worker/out/Release Directory does not contain a valid build tree: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release The Meson build system Version: 0.60.2 Source dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker Build dir: H:\workspace\edumeet-master\server\node_modules\mediasoup\worker\out\Release Build type: native build Project name: mediasoup-worker Project version: undefined C compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �Ż������� 19.16.27045 ��") C linker for the host machine: link link 14.16.27045.0 C++ compiler for the host machine: cl (msvc 19.16.27045 "���� x64 �� Microsoft (R) C/C++ �Ż������� 19.16.27045 ��") C++ linker for the host machine: link link 14.16.27045.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Downloading openssl source from https://www.openssl.org/source/openssl-1.1.1l.tar.gz Download size: 9834044 Downloading: ...
PS:此时如果指定安装旧一点版本的 mediasoup ,比如 3.5.14 还会失败...不久之前更改了编译方案的原因,旧的需要改配置。