Packaging and creating a dedicated server

Hello everyone!

I’m currently working on a game where several players are supposed to be able to connect to a server and then play with each others. I got everything to work while i was using the dedicated server available to launch within the editor, but as soon as i tried create a server otherwise it failed.

I’ve red about packaging and getting a server exe with it, but can anyone help me how to do this?



I’ve also been struggling with figuring out how to do this. I can launch the dedicated server using UE4Editor.exe, but without the memory optimizations that exist in a shipping dedicated server I’ve been unable to assess the practicality of my current project in a real-world scenario.

If anyone could provide any information, it would be greatly appreciated.

Can you share the process to get this to work? I’ve tried several ideas posted on this forum as well as digging around on my own but either the process crashes at start-up or the client loads. I’m just looking to load a headless server process.

If you’re referencing the ShooterGame demo (possibly others), I’ve found through talking with the Epic staff that there is a target file missing (possibly in other projects as well) from the GitHub that enables the building of the dedicated server .exe files.

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class ShooterGameServerTarget : TargetRules
	public ShooterGameServerTarget(TargetInfo Target)
		Type = TargetType.Server;
		bUsesSteam = true;

	// TargetRules interface.

	public override bool GetSupportedPlatforms(ref List<UnrealTargetPlatform> OutPlatforms)
		// It is valid for only server platforms
		return UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms(ref OutPlatforms, false);

	public override void SetupBinaries(
		TargetInfo Target,
		ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
		ref List<string> OutExtraModuleNames
    public override List<UnrealTargetPlatform> GUBP_GetPlatforms_MonolithicOnly(UnrealTargetPlatform HostPlatform)
        if (HostPlatform == UnrealTargetPlatform.Mac)
            return new List<UnrealTargetPlatform>();
        return new List<UnrealTargetPlatform> { HostPlatform, UnrealTargetPlatform.Linux };

    public override List<UnrealTargetConfiguration> GUBP_GetConfigs_MonolithicOnly(UnrealTargetPlatform HostPlatform, UnrealTargetPlatform Platform)
        return new List<UnrealTargetConfiguration> { UnrealTargetConfiguration.Development, UnrealTargetConfiguration.Shipping };

Hope that helps somebody…

A more official answer that I hope will help out in the interim. should be in GitHub as of the 4.1 release.

The distributed binaries for the editor that come from the launcher do not include compilation against a preprocessor define UE_SERVER which gives you the optimizations and some additional parts required to run in the server executable mode. I’m not sure at the moment what the plan is, but I would assume that this isn’t supported in this fashion for the time being. There was a bug filed to make this more clear that will be in the next release (not 4.1 because that is imminent).

That being said, you have all the code to compile the full engine source in GitHub and can GenerateProjectFiles.bat to make the UE4.sln file that will have your project and all our modules included. If you compile this in as “Debug Server”, “Release Server”, etc you will get the server executable (MyGameServer.exe) to compile properly. In this mode you will need to cook your content via UFE so that it has data to run with.

As always, the editor can run in -game and -server modes for emulation of MyGame.exe and MyServer.exe respectively.

I hope this helps and will dig further if necessary.

I’ve seen a lot of posts pointing to this bit of code for a new server target, but I’m unable to get it to compile.

I’m basically trying to get a dedicated server build target added to a minimal new project, but adding a build target will simply produce a MASSIVE amount of unresolved external symbols.

You’d think that there would be more posts about this and more solutions or even guides on how to implement a new (server) build target.

See my post above. Running from the “binary” version of the engine will not allow you to compile dedicated server. There are many permutations for our static libs and it was decided that compiling with UE_SERVER=1 was not one of them.

You will have to get the source code from GitHub, get your project included when you GenerateProjectFiles.bat (either by setting your project next to \Engine\ or making sure your uproject files are setup correctly) and then build a Server for Win32/Win64 to generate a MyGameServer.exe file.

Additionally you will have to cook for WindowsServer target in order to have content to run with that binary. You have to use UnrealFrontend.exe (in the binaries directory or you compile) to cook the data.

Although I’m doing my best to advise, apparently this is in the “unsupported” state at the moment. It’s rough but we’ll get it going for you.

That actually makes sense, I just thought that the necessary headers/source for this kind of functionality would’ve been included with the official binary, but I’m guessing you’re working on adding dedicated server packaging/building to the binary at some point.

To be honest, this wasn’t trivial or ideal by any means, but here’s how I managed to get it building:

  1. Get the source, build it and run the version selector
  2. Run the Editor from the built binaries
  3. Create a new, empty project
  4. Add any kind code (I just made an actor called TestActor) from the File menu
  5. Close Visual Studio if/when it opens
  6. Add Server.Target.cs and modify to match
  7. In your .Build.cs, uncomment Slate and OnlineSubsystem
  8. With Visual Studio closed, in the Editor go to File → Refresh Visual Studio
  9. Now you see the Server target option in VS and you can actually build it, as all headers and libraries are included and pointing at the right files

It still hasn’t finished building though, but at least I’m getting further than I was before.

I really appreciate your willingness to share the steps and make the time. I’ll get this feedback to our QA group to see if this it the current "best way’. It’s hard sometimes to see how the other half lives. I was planning on trying some things out at home myself to see the pain points.

No problem! This might be a tad off-topic, but I did notice some oddities between the binary and source-built Editor:

If I create an empty project with the binary Editor, I don’t see anything related to Visual Studio in the File-menu, so I have to create a class/object manually and then the Editor will generate the project files.

If I do the same, but with the source-built Editor, I immediately see the option for refreshing the Visual Studio project etc. but clicking on it just gives me an error, as the project doesn’t exist yet. So I have to manually add a class/object and it’ll generate the project files, like before.

Just thought I’d share that bit too, as it does seem a bit odd to have to actually create an object before being able to create a VS project (maybe that’s just me?) and the fact that the source version shows the option is a bit misleading.

I would strongly consider starting a separate support/question thread about that issue so it isn’t lost here. I’m not the best source for information on the project wizards and creation and how they differ work across “binary only” and “github source”.

Regarding the dedicated server target, I still haven’t been able to successfully run the server, as the cooking step isn’t as clear as I thought it would be.
Using UnrealFrontend to Cook for just “WindowsServer” results in an error while cooking.
I’ve created my own batch files (by studying the ShooterGame 4.1 batch files) for both the client and the server, and while that doesn’t create a .pak file, it does copy the 3rd party DLL’s, content etc. into separate directories and the executable in it’s own directory, just like in the ShooterGame deployment batch files.
Neither the client or the server run at all, they just produce a minidump or throw errors.
The only way I’ve been able to run the client so far, is by using the editor’s deployment (& cooking).

To reiterate: Unreal Frontend’s cooking errors on both the client and the server. The steps that I listed above only get you as far as building the binary, but knowing where the binary is expecting to read the files from and how to properly cook the files to get it working, is really beyond me at this point.

UPDATE: Selecting plain “Windows” as the target in UFE does succesfully cook, apparently.

UPDATE 2: Packaging with the Editor and disabling .pak file generation, then copying the server binary in the binary folder seems to be working. The server runs, although it only seems to go straight to the background, I would’ve assumed it would have created a command line or something to interact with it or to close it with. Getting further now though, I suppose.

I’ve been looking around for information on this and ended up posting in the forums myself.
To add to this, trying to Debug the Server code is even more painfull :slight_smile:
Localization is where my issues are occuring …
Any updates on this would be highly appreciated.
The basic game setup is easy, the real work is setting up a dedicated server
Once I can debug the server I can easily get it talking to my Master Server
system with sockets, but I need to be able to run it in debug mode…

Could you please make a short video tutorial on this? I’m really confused cause I don’t have lot’s of experience in compiling from source code… In was expected not to work with engine source code but only with a distributed release…

I wrote a blog post detailing the steps I took to build, run, and connect to a dedicated server. I hope this helps!

I compiled most of the things you figured out into a guide as I went through the process myself. I think there are some issues, though. Have a look if you feel so inclined: piinecone — Building a dedicated server in Unreal Engine 4

This is the best tutorial to use is this link: Dedicated Server Guide (Windows & Linux)

I have used this method multiple times and had a success each time.

Close Visual Studio if/when it opens

Add Server.Target.cs and modify to match

How do you add the Server Target, when visual studio is closed?

He’s referring to the target.cs file you have for your game. You need to make a target.cs file for the server and change the rules/type inside to “server”.

Try looking here for what I mean.

Dedicated Server Project Settings

Hey, Pinecone - did you, by any chance, ever look at doing the Mac dedicated server?