Dedicated Server using Unreal Engine as a Library

Hello there,
I’m currently trying to figure out, if it’s possible to link my a dedicated server into a third-party application using Unreal Engine as a library.

Before I now go down this rabbit hole and in the end find out, that it’s neither feasible nor legal (UE as a library is governed as Engine Tools, if I recall correctly) I’d like to ask you guys if anyone has ever tried this before.

From what I gathered from the documentation, Unreal Engine as a library currently only supports monolithic editor builds. Does that mean, that it won’t be possible to e.g. compile my dedicated server, link it to my own application and start it from there?

I’d be really glad, if someone who has already worked with the library could give me some input on that.

Thank you in advance and also feel free to just express your thoughts. Maybe I’m looking at it from the completely wrong angle and it is fully unneeded, since you can already achieve that with normal dedicated server builds. The main thought behind it is basically provisioning and control in a distributed environment.

It’s all C++ code. There’s really nothing special about being the “main” other than that’s where the OS starts the program, and the first thread it creates.

You can build your own server by simply renaming the “main” function (or WinMain) out of Unreal to something else, and calling “pthread_create” or “_beginthreadex,” passing in a thread function that calls the unreal main function.

You could also, as an alternative, insert your own code into the unreal main function, that spawned a thread that called your servers “main” function, renamed to something else (so you don’t get a link collision.) This would work just as well. There would be no real difference.

As far as I can tell, the problem with “shipping the editor” in the license, is just that – don’t ship the editor bits. You can re-build the engine with a different name for the “main” function, without turning on the editor bits, and your server would be like just any other unreal game server instance, covered by that same license.

(But if you want any kind of assurance that “this will hold up in court if Epic decides to sue you,” then that will have to be evaluated by someone competent in both software engineering, and law, and licensed to do so. Such lawyers are super hard to find, and expensive. That being said, my personal risk profile would not sweat it, because to me it looks the same as a custom engine build, as long as you don’t include the editor builds, or any licensed third-party libraries used by only the editor.)

1 Like

Thank you for the reply and the input!
The main reason I wanted to use UE as a library, was that I didn’t want to fork the engine and make deeper changes to it. I kind of like the idea to link-in the server and just extend its API for needed functionality.
Especially while working with UE5 right now it feels kind of wasted to maintain a fork, looking at how the product is not yet final and will probably require multiple merges.
I’ll definitely have a look into what you suggested, basically just altering the code to be called from my external application. I just thought since the UELibrary feature was already introduced that I might build it up on that.

From the legal aspect. Even though I’m not clear for now, how it’s going to be evaluated, I’m currently not too worried about that. I’d rather try for a PoC first before worrying about the legal issues.

If you don’t want to change the code at all, the easiest thing to do is to build your custom server as a plugin to Unreal.
You get static constructors, and you get subsystem init pretty early on, when you can spawn your own thread that runs your own main-like loop.
If the only question is “how do I forward argv[]” then perhaps you can have a config file where the argv for your server is some particular configuration value, and then you split it apart in the adapter code?