keywords: UE4, Android, Packaging, Building, Deployment

Common Cases

How to include engine third party in game

Add third party name (the directory name in Engine\Source\ThirdParty\ or in Engine\Source\Runtime\) in PublicDependencyModuleNames in Build.cs.

e.g.

PublicDependencyModuleNames.AddRange(
new string[]
    {
        "HTTP",
        "OpenSSL",
        "libcurl",
        "libWebSockets",
        "Foliage"
    }
);

HTTP was in Engine\Source\Runtime\Online\HTTP, and Foliage was in Engine\Source\Runtime\Foliage. If there’s a .Build.cs under a directory, that means we can add the name of directory into PublicDependencyModuleNames.

If want to add WebSocket in your project, you can add either WebSockets or libWebSockets in PublicDependencyModuleNames, because there’re two libraries of WebSocket, which are in Engine\Source\Runtime\Online\WebSockets and Engine\Source\ThirdParty\libWebSockets, in engine.

How to override config files (DefaultGame.ini) after Packaging?

Example of GameUserSettings.ini:

Engine\Source\Runtime\Engine\Classes\GameFramework\GameUserSettings.h

Config file directory for package:

WindowsNoEditor\Stars\Saved\Config\WindowsNoEditor\GameUserSettings.ini
How to change save directory for shipping package

append argument -NotInstalled on game startup

MyGame.exe -NotInstalled
How to disable plugin compiling in specified platform

Add WhitelistPlatforms in .uplugin:

"WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android", "Linux" ]

Example:

"Modules": [
    {
        "Name": "UnLua",
        "Type": "Runtime",
        "LoadingPhase": "PreDefault",
        "WhitelistPlatforms": [ "Win64", "Mac", "IOS", "Android", "Linux" ]
    },
    {
        "Name": "UnLuaEditor",
        "Type": "Editor",
        "LoadingPhase": "Default",
        "WhitelistPlatforms": [ "Win64", "Mac" ]
    }
]

Reference:
https://github.com/Tencent/UnLua/blob/master/Plugins/UnLua/UnLua.uplugin

Linux

Cross-Compiling for Linux

Cross-Compiling for Linux
https://docs.unrealengine.com/en-US/Platforms/Linux/GettingStarted/index.html

How to Cross-Compile for Linux in Unreal Engine - Setting up the Toolchain
https://www.youtube.com/watch?v=WKRi8bZCsFM

Building Unreal Engine Game Client and Dedicated Server on Linux
https://gist.github.com/zhiguangwang/42b0584ae689f0f8711790e4c05d76f1

Building and Hosting an Unreal Engine Dedicated Server with AWS and Docker
https://medium.com/swlh/building-and-hosting-an-unreal-engine-dedicated-server-with-aws-and-docker-75317780c567

Run UE4 on Linux

Linux Quick Start. Learn how to download, build, and run UE4 on Linux. https://docs.unrealengine.com/en-US/SharingAndReleasing/Linux/BeginnerLinuxDeveloper/SettingUpAnUnrealWorkflow/index.html

Linux Issues - Failed to load Vulkan Driver

Error on startup editor on Linux:

Failed to load Vulkan Driver which is required to run the engine. The engine no longer fallbacks to OpenGL4 which has been deprecated.

Solution:

yum install libvulkan1 mesa-vulkan-drivers vulkan-utils

Reference:
https://linuxconfig.org/install-and-test-vulkan-on-linux

Linux Issues - ThirdParty/CEF3/Linux: not in executable format: Is a directory

Error while running UE4 client on Linux:

Error while mapping shared library sections:
`/home/stars_client/LinuxNoEditor_debuggame/Stars/Binaries/Linux/../../../Engine/Binaries/ThirdParty/CEF3/Linux': not in executable format: Is a directory

Solution:
Add USE_NULL_RHI=1 in [Project].Build.cs

if(Target.Platform == UnrealTargetPlatform.Linux && Type == TargetType.Game)
{
    GlobalDefinitions.Add("USE_NULL_RHI=1");
    System.Console.Out.WriteLine("===================== USE_NULL_RHI=1");
}
How to generate core dump file when games crashed in shipping on Linux

Pass -core when running applicaton on Linux:

MyProj/Binaries/MyProjServer-Linux-Shipping -core -log -port=7777

Deubg in Shipping

Displaying Debug information

Project Settings -> Packaging -> Project -> check Include Debug Files.

Logging

Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs

/// <summary>
/// Whether to turn on logging for test/shipping builds.
/// </summary>
[RequiresUniqueBuildEnvironment]
public bool bUseLoggingInShipping = true;

Or modify [Project].Target.cs:

if (Configuration == UnrealTargetConfiguration.Shipping)
{
    bUseLoggingInShipping = true;
}
Check

Engine\Source\Programs\UnrealBuildTool\Configuration\TargetRules.cs

/// <summary>
/// Whether to turn on checks (asserts) for test/shipping builds.
/// </summary>
[RequiresUniqueBuildEnvironment]
public bool bUseChecksInShipping = true;

Or modify [Project].Target.cs:

if (Configuration == UnrealTargetConfiguration.Shipping)
{
    bUseChecksInShipping= true;
}
Console Command

Engine\Source\Runtime\Core\Public\Misc\Build.h

#ifndef ALLOW_CONSOLE_IN_SHIPPING
    #define ALLOW_CONSOLE_IN_SHIPPING 1
#endif

Or modify [Project].Target.cs:

if (Configuration == UnrealTargetConfiguration.Shipping)
{
    GlobalDefinitions.Add("ALLOW_CONSOLE_IN_SHIPPING=1");
}

[Available]
Some stat commands such as stat unit, stat levels, stat fps
Some dump commands such as dumpticks, dumplevelcollections, etc.
open, travel, log, r.xxx, a.xxx, t.xxx, gc.xxx, etc.

[Unavailable]
Some stat commands such as stat unitgprah, stat collision, stat startfile / stopfile
A series of commands such as showflag, obj, memreport
shot/hiresshot, toggledrawevents, profilegpu

Stats

Engine\Source\Runtime\Core\Public\Misc\Build.h

/** Compile flag to force stats to be compiled */
#ifndef FORCE_USE_STATS
    #define FORCE_USE_STATS 1
#endif

Or modify [Project].Target.cs:

if (Configuration == UnrealTargetConfiguration.Shipping)
{
    GlobalDefinitions.Add("FORCE_USE_STATS=1");
}

Reference:
https://qiita.com/donbutsu17/items/76ea5c5531aa4da77f9d

Issues

UE4 Editor modifies the value of GlobalDefinitions. This is not allowed.

Error on building:

UE4 Editor modifies the value of GlobalDefinitions. This is not allowed, as MyProjectEditor has build products in common with UE4Editor.

Solution:

Add BuildEnvironment = TargetBuildEnvironment.Unique; into MyEditor.Target.cs

BuildEnvironment = TargetBuildEnvironment.Unique;
GlobalDefinitions.Add("AAA=1");

Origin:
https://answers.unrealengine.com/questions/920431/view.html


岂能尽如人意,但求无愧我心。──丁聪