Because the build tools of UE4 works across platforms (Windows, Mac OS, Linux), steps in this article can be applied to Mac OS and Windows as well.
On Windows, You need to replace RunUAT.sh
with RunUAT.bat
though.
First, get Unreal Engine 4 sourcecode and export the following environment variables:
- $UE4_ROOT Engine sourcecode directory, which contains
Setup.sh
- $GAME_UPROJECT Path of the
.uproject
file of your game project - $ARCHIVED_DIR Your build output directory.
cd $UE4_ROOT
./Setup.sh
./GenerateProjectFiles.sh
make UE4Editor UE4Game UnrealPak CrashReportClient ShaderCompileWorker UnrealLightmass
This will generate Makefiles on Linux (Visual Studio files on Windows, XCode files on Mac OS).
$UE4_ROOT/GenerateProjectFiles.sh -project="$GAME_UPROJECT" -game
You will need to make a copy of your game client build targets for the Server target. In your project_dir/sources folder you will find editor and game target .cs files. Create a copy of [ProjectName].Target.cs and rename it [ProjectName]Server.Target.cs.
Edit your new file and change the occurrences to add Server as a target.
Also set TargetType to Server
. See the following example:
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class [YourProject]ServerTarget : TargetRules // Please notice the added Server
{
public [YourProject]ServerTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Server; // Changed from Game to Server!
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.Add("NodejsTest");
}
}
$UE4_ROOT/Engine/Build/BatchFiles/RunUAT.sh \
BuildCookRun -project="$GAME_UPROJECT" \
-nop4 -build -cook -compressed -stage \
-noclient -server -serverplatform=Linux -serverconfig=Development \
-pak -archive -archivedirectory="$ARCHIVED_DIR" \
-utf8output
$UE4_ROOT/Engine/Build/BatchFiles/RunUAT.sh \
BuildCookRun -project="$GAME_UPROJECT" \
-nop4 -build -cook -compressed -stage \
-platform=Linux -clientconfig=Development \
-pak -archive -archivedirectory="$ARCHIVED_DIR" \
-utf8output