当前位置: 首页 > 工具软件 > obs-browser > 使用案例 >

windows下编译obs遇到的错误及解决

卓嘉良
2023-12-01

obs是国外开源的直播推流工具,用的很多。本人从 https://github.com/obsproject/obs-studio下载源码编译,具体的过程请参考https://github.com/obsproject/obs-studio/wiki/Install-Instructions#windows-build-directions,但这个要求使用VS2017编译,我的还是VS2015,编译的是Win32 Release版本,实际上也是可以编译通过的。

这里记录一下遇到两个错误:

1.一个是text-freetype2项目报的:

>------ 已启动生成: 项目: text-freetype2, 配置: Release Win32 ------
>    正在创建库 /build/plugins/text-freetype2/Release/text-freetype2.lib 和对象 /build/plugins/text-freetype2/Release/text-freetype2.exp
>freetype.lib(bdf.obj) : error LNK2019: 无法解析的外部符号 __imp__sprintf,该符号在函数 __bdf_parse_properties 中被引用
>\build\plugins\text-freetype2\Release\text-freetype2.dll : fatal error LNK1120: 1 个无法解析的外部命令

解决:需要在该项目的属性 -> 链接器 -> 输入 -> 附加依赖项 增加一个依赖库legacy_stdio_definitions.lib

2.另一个是obs项目报的:

>------ 已启动生成: 项目: obs, 配置: Release Win32 ------
>  window-basic-preview.cpp
>\obs-studio-master\UI\window-basic-preview.cpp(932): error C2719: “transform”: 要求 16 对齐的形参将不被对齐

解决:将932行的transform变量的传参类型由值传递改为引用,如下:

static bool IntersectBox(matrix4& transform, float x1, float x2, float y1,
             float y2)

原因就在于matrix4的定义用到了vec4,而vec4的定义又用到了__m128,而这个__m128在定义的时候前面有个__declspec(align(16)),限制结构体内存对齐为2字节,值传递过程会产生新的变量,与传参的内存对齐不同。

 

 

 类似资料: