UE4.27.2 源码使用 VS2022 编译时出现的错误的解决方法

目录

    • [Error C4834 discarding return value of function with 'nodiscard' attribute](#Error C4834 discarding return value of function with 'nodiscard' attribute)
    • [Windows SDK 的问题](#Windows SDK 的问题)
    • [compiler heap 不足的问题](#compiler heap 不足的问题)

Error C4834 discarding return value of function with 'nodiscard' attribute

Fstring 的获得指针的函数是 nodiscard 的,但是目前这个表达式是可能 discard 的

https://forums.unrealengine.com/t/build-from-source-fails-with-errors-c4834-and-msb3073/1266696/4

Windows SDK 的问题

我遇到的错误如下

复制代码
Severity	Code	Description	Project	File	Line	Suppression State
Error	C4668	'_NOEXCEPT_TYPES_SUPPORTED' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'	UE4	C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt\wrl\event.h	211	
Error	C4668	'__cpp_noexcept_function_type' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'	UE4	C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt\wrl\event.h	211	
Error	C4668	'_NOEXCEPT_TYPES_SUPPORTED' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'	UE4	C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt\wrl\event.h	371	
Error	C4668	'__cpp_noexcept_function_type' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'	UE4	C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\winrt\wrl\event.h	371	
Error	MSB3073	The command "..\..\Build\BatchFiles\Build.bat -Target="UE4Editor Win64 Development" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 6.	UE4	E:\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets	44	

这应该是说明 10.0.22621.0 是不适用的

我在网上看到了别人的解决办法是只保留 Win 10 的 SDK,不要 Win 11 的 SDK

https://zhuanlan.zhihu.com/p/584575858

因为我觉得直接修改所有项目要求的 Windows SDK 版本也是一样的效果,所以一开始我没有卸载 Win 11 的 SDK,然后企图使用重定向的那个功能来更改版本

但是失败了......即使点了确定,再次打开重定向窗口显示的仍然是旧版本

上网看了,这个 VS 的 Bug 有一段时间了

vcxproj 也不是只读的,所以应该是 VS 内部的问题

这个解决方案有七十多个项目,如果要一个一个去 vcxproj 里面改版本,那就累死......

于是我还是把 Win 11 的 SDK 删了,这样他就会默认用我 Win 10 的

然后他说要重启电脑,重新运行 Setup.bat 和 GenerateProjectFiles.bat,这个我没有,我就可以直接开始 build UE4 项目了

花的时间还是很长的......

compiler heap 不足的问题

最后是能编译,但是等了一个小时左右之后,报错说 compiler heap 不足

一开始我想的是把虚拟内存调大一点,但是我设置了之后没有反应,于是我想查查别的方法

于是查到了

https://ue5wiki.com/wiki/5cc4f8a/

把工程中的 BuildConfiguration.xml 修改一下就好了

xml 复制代码
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
    <WindowsPlatform>
        <PCHMemoryAllocationFactor>1000</PCHMemoryAllocationFactor>
    </WindowsPlatform>
    <LocalExecutor>
        <MaxProcessorCount>60</MaxProcessorCount>
    </LocalExecutor>
    <ParallelExecutor>
        <MaxProcessorCount>60</MaxProcessorCount>
    </ParallelExecutor>
</Configuration>
相关推荐
Yuk丶2 天前
厌倦了假AI对话?本地 LLM 语音对话 + 口型同步系统 2.0(已开源!)
c++·人工智能·语言模型·开源·ue4·语音识别·游戏开发
归真仙人3 天前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine
上山老人13 天前
UE4布娃娃约束修改
ue4
Yuk丶17 天前
厌倦了假AI对话?用本地大模型给UE注入真智能(已开源!)
c++·人工智能·开源·ue4·游戏程序·ue4客户端开发
emplace_back19 天前
UE 使用UE4PrereqSetup_x64.exe一键安装依赖
ue4
Yuk丶22 天前
LPM的AI 角色三大核心技术实现:长效记忆、人格锁定、低延迟口语化
人工智能·ai·ue4·虚幻·ue4客户端开发
归真仙人24 天前
【UE】Lightmass可执行文件已经过时
ue5·游戏引擎·ue4·虚幻·unreal engine
DoomGT25 天前
Design - 一些免费图标网站
ue5·ue4·虚幻·虚幻引擎·unreal engine
归真仙人1 个月前
【UE】VR一体机转场
ue5·ue4·vr·虚幻引擎·unreal engine
洋洋06171 个月前
UE4/UE5 引擎常见面试题总结(1)
ue5·ue4