How to fix and compile UE4 with Microsoft Visual Studio 2017

How to fix and compile UE4 with Microsoft Visual Studio 2017

How to fix and compile UE4 with Microsoft Visual Studio 2017 150 150 noir

In some case of UE4 compilation through the vs2017 the errors are appearing and cause fatal error, so you cant compile the UE4.

the following components generate an error:

UnrealFrontend
UnrealCEFSubProcess
ShaderCompileWorker
UnrealLightmass
UnrealVersionSelector
CrashReportClient
BootstrapPackagedGame
UnrealPak
UnrealWatchdog
BlankProgram
BuildPatchTool
ShaderCacheTool
SlateViewer
MinidumpDiagnostics
SymbolDebugger
TestPal
UnrealFileServer
UE4

all of them have the same error: C2187 syntax error: ‘identifier’ was unexpected here C:\Program Files (x86)\Windows Kits\8.1\include\um\combaseapi.h 229, and also all of the errors point to that one file in windows 8.1 sdk.

 

How To Fix:

Step one:

open Engine/Source/Programs/Windows/BootstrapPackagedGame/Private/BootstrapPackagedGame.h then add struct IUnknown; near line 2, after  the changes, the code is should be look like this.

#pragma once

struct IUnknown; // ADD THIS LINE

#include <windows.h>
#include <tchar.h>
#include <assert.h>

 

Step two:

open Engine/Source/Runtime/Core/Public/Windows/MinWindows.h then near line 63, 64 add this line of code: struct IUnknown;

#define NOPROXYSTUB
#define NORPC

struct IUnknown; // ADD THIS LINE

 // Finally now we can include windows.h
#include <Windows.h>

In some cases at this moment everything is fine and you can compile the code via VS2017, but in other cases it doesnt fixed right now, and you need to make some other changes so you need to amend the Build Tool chain file at Engine/Source/Programs/UnrealBuildTool/Windows/VCToolChain.cs, then search for /permissive- and when you find the line, Add Arguments.Add(“/Zc:twoPhase-“); as marked below.

// Disable Microsoft extensions on VS2017+ for improved standards compliance.
if (Compiler >= WindowsCompiler.VisualStudio2017)
{
    Arguments.Add("/permissive-");
    Arguments.Add("/Zc:twoPhase-"); // <-- ADD THIS LINE
    Arguments.Add("/Zc:strictStrings-"); // Have to disable strict const char* semantics due to Windows headers not being compliant.
}

Then rebuild your project, now everything is fine.

 

Was this post helpful?