[UE4]Engine Source Compilation Issues Collection
Keywords: UE4, VS 2019 building from source failed
Common
error C4668: ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro
Error:
error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
Solution:
Wrap windows.h
with AllowWindowsPlatformTypes.h
and HideWindowsPlatformTypes.h
#include "Windows/AllowWindowsPlatformTypes.h"
#include <windows.h>
#include "Windows/HideWindowsPlatformTypes.h"
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error:
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Caused by:
Header contains macros defined in other headers, but current header doesn’t include these headers.
e.g. *.generated.h.
Solution:
Add includes:
#include "MyActor.generated.h"
VS 2019
fatal error C1083 Cannot open include file ’typeinfo.h’
Issue:
Building from engine source failed:
fatal error C1083: Cannot open include file: 'typeinfo.h': No such file or directory
Caused by:
It’s a issue of version 4.22.
https://issues.unrealengine.com/issue/UE-81677
Solution:
replace #include <typeinfo.h>
with #include <typeinfo>
, no .h
.
error C4800: Implicit conversion from ‘ADODB::_Recordset *const ’ to bool. Possible information loss
Error on building source:
error C4800: Implicit conversion from 'ADODB::_Recordset *const ' to bool. Possible information loss
error C4800: Implicit conversion from 'EnvDTE::Thread *const ' to bool. Possible information loss
Caused by:
Type checking at compilation time is more strict in VS 2019.
Solution:
Add Arguments.Add("/wd4800");
in Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs
.
void AppendCLArguments_CPP(CppCompileEnvironment CompileEnvironment, List<string> Arguments)
{
if (Target.WindowsPlatform.Compiler != WindowsCompiler.Clang)
{
// Explicitly compile the file as C++.
Arguments.Add("/TP");
Arguments.Add("/wd4800");
Reference:
https://stackoverflow.com/questions/60943495/error-compiling-unreal-engine-4-24-1-after-updating-visual-studio-2019
https://blog.csdn.net/maxiaosheng521/article/details/95196841
Or:
Modify engine source:
https://github.com/EpicGames/UnrealEngine/commit/25cefc81fe24c767eb995b0bb66b5611e0596973?diff=unified
LogCompile : error : Failed to initialize the engine (PreInit failed).
Error on building source:
2>C:\MyProj\Intermediate\ProjectFiles\LogCompile(0,0): Error : Failed to initialize the engine (PreInit failed).
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): Error MSB3073 : The command "C:\Windows\System32\chcp.com 65001 >NUL
E:\UnrealEngine\Engine\Build\BatchFiles\Build.bat -Target="StarsEditor Win64 DebugGame -Project=\"C:\MyProj\MyProj.uproject\"" -Target="ShaderCompileWorker Win64 Development -Quiet" -WaitMutex -FromMsBuild" exited with code 3.
Solution:
Delete all intermediate files in Plugins
directory.
VS 2022
Error CS0234: The type or namespace name ‘Management’ does not exist
Error CS0234 The type or namespace name 'Management' does not exist in the namespace 'Windows' (are you missing an assembly reference?) HoloLens.Automation C:\ue4\Engine\Source\Programs\AutomationTool\HoloLens\HoloLensPlatform.Automation.cs 17 Active
Error CS0246 The type or namespace name 'IAsyncOperationWithProgress<,>' could not be found (are you missing a using directive or an assembly reference?) HoloLens.Automation C:\ue4\Engine\Source\Programs\AutomationTool\HoloLens\HoloLensPlatform.Automation.cs 1235 Active
Error CS0246 The type or namespace name 'DeploymentResult' could not be found (are you missing a using directive or an assembly reference?) HoloLens.Automation C:\ue4\Engine\Source\Programs\AutomationTool\HoloLens\HoloLensPlatform.Automation.cs 1235 Active
Error CS0246 The type or namespace name 'DeploymentProgress' could not be found (are you missing a using directive or an assembly reference?) HoloLens.Automation C:\ue4\Engine\Source\Programs\AutomationTool\HoloLens\HoloLensPlatform.Automation.cs 1235 Active
Solution:
Install UWP component for Visual Studio.
Error while enumerating Visual Studio toolchains
Create project from UE4Editor failed:
Error while enumerating Visual Studio toolchains
Solution:
Install UWP component for Visual Studio.
error C2440: cannot convert from ‘const From *’ to
UE5 building error:
Engine\Source\Runtime\Core\Public\Containers\StringConv.h(1048): error C2440: '<function-style-cast>': cannot convert from 'const From *' to 'TStringConversion<TStringConvert<From,To>,128>'
Solution:
Install individual components: MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.29-16.11)
Fragments
error LNK2019: unresolved external symbol class FMaterialResource * __cdecl FindOrCreateMaterialResource()
Solution:
Not only add Engine
in PublicDependencyModuleNames
(.Build.cs), but also change the DLL export/import declarations of function.
Old:
extern FMaterialResource* FindOrCreateMaterialResource() { }
New:
ENGINE_API FMaterialResource* FindOrCreateMaterialResource() { }
References:
https://forums.unrealengine.com/t/what-does-coreuobject-api-engine-api-macro/279675
Man is the cruelest animal. ― Friedrich Nietzsche