VS2022编译OBS

VS2022编译obs-studio-28.1.2

前言

obs-studio-28.1.2出来已经有一段时间了,今天就尝试编译一下,顺便记录一下我编译的过程。

准备工作

自动 Windows 构建允许以最少的输入和设置构建 OBS。自动安装必要的依赖项,构建标志使用合理的默认值,生成的 OBS 构建使用应用程序的完整功能集:
1.Windows PowerShell(v5+ 和更新版本);
2. Visual Studio 2022(至少是社区版);
3. windows 10 sdk(最低 10.0.20348.0);
以上不清楚的自行百度

构建过程

运行Windows PowerShell,切换到指定目录,下载源码:

git clone --recursive https://github.com/obsproject/obs-studio.git

切换到源码目录,然后运行以下命令之一

#Download and set up dependencies, then build OBS for local host
#architecture with common feature set

CI/build-windows.ps1

#Check for dependencies installable via Chocolatey

CI/build-windows.ps1 -Choco

#Skip download and setup of dependencies

CI/build-windows.ps1 -SkipDependencyChecks

#Build 32-bit only

CI/build-windows.ps1 -BuildArch '32-bit'

#Build both architectures

CI/build-windows.ps1 -CombinedArchs

#Create a zip archive with OBS and all required libraries
CI/build-windows.ps1 -Package

#Create a debug build

CI/build-windows.ps1 -BuildConfiguration Debug

#Use my_build_dir prefix as build directory

CI/build-windows.ps1 -BuildDirectory my_build_dir

#Build and package a combined 64-bit and 32-bit of OBS with Release configuration,
#using more verbose output and skipping dependency checks

CI/build-windows.ps1 -SkipDependencyChecks -CombinedArchs -BuildConfiguration Release -Verbose

#Show all available options

CI/build-windows.ps1 -Help

我直接运行的是第一个脚本CI/build-windows.ps1

问题记录:

1、编译过程会遇到Windows PowerShell没有权限运行脚本问题
权限问题。Powershell脚本的4种执行权限介绍,Windows默认不允许任何脚本运行,
我们可以使用"Set-ExecutionPolicy"cmdlet来改变的PowerShell环境,共有4种运行权限:
Restricted——默认的设置, 不允许任何script运行
AllSigned——只能运行经过数字证书签名的script
RemoteSigned——运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名
Unrestricted——允许所有的script运行
解决方法:
管理员运行Windows PowerShell输入下面命令:

set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy Unrestricted-Scope CurrentUser

2、报错:该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
解决方法:
在源码目录的 CMakeList.txt 中加入如下内容即可

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

就这么简单接下来,你只要看着脚本帮你完成一切工作就ok了。

2023-3-30编译了obs29.1.0版本。
记录:

---------------------------------------------------------------------------------------------------------------------------------------
1、下载obs
git clone --recursive https://github.com/obsproject/obs-studio.git
注意很多别的用户提交的模块下载不了,要单独下载。如:
enc-amf
obs-browser
obs-websocket
libdshowcapture	
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
2、打开Windows PowerShell,切换到obs下载目录
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
3、脚本编译安装obs
CI/build-windows.ps1
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
4、出现错误1:
CI/build-windows.ps1 : 无法加载文件 D:\project2023\VC\obs\obs-studio\CI\build-windows.ps1,因为在此系统上禁止运行脚本。
有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ CI/build-windows.ps1
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
解决办法:
set-ExecutionPolicy Unrestricted
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
5、出现错误2:
Error while installing winget package 7zip.7zip: 无法将“winget”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请
检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 D:\project2023\VC\obs\obs-studio\CI\include\build_support_windows.ps1:189 字符: 17
+ ...             throw "Error while installing winget package ${Package}:  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Error while ins...请确保路径正确,然后再试一次。:String) [], RuntimeEx
ception
    + FullyQualifiedErrorId : Error while installing winget package 7zip.7zip: 无法将“winget”项识别为 cmdlet、函数、
脚本文件或可运行程序的名称    。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
解决办法:
下载win10自带的winget包管理工具
下载网址:
https://github.com/microsoft/winget-cli/releases?page=4

Windows PowerShell安装.appxbundle后缀的winget
Add-AppxPackage -Path "C:\Users\Administrator\Downloads\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle"
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
6、出现错误3:
Invoke-Expression : 无法将“7z”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 D:\project2023\VC\obs\obs-studio\CI\windows\01_install_dependencies.ps1:83 字符: 9
+         Invoke-Expression "7z x vlc_${Version}.zip -ovlc"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (7z:String) [Invoke-Expression], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.InvokeExpressionCommand
解决办法:
安装7-ZIP
下载网站:
https://7-zip.org/
安装后把安装路径设置到系统环境变量,重启电脑。
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
7、出现错误4:
OBS: OBS -websocket子模块deps不可用。
子模块deps为空,重新下载。
---------------------------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------------------------
8、出现错误5:
OBS: OBS -win-dshow子模块capture-device-support找不到
子模块capture-device-support为空,重新下载。
---------------------------------------------------------------------------------------------------------------------------------------
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

捌玖ヾ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值