Announcement

Collapse
No announcement yet.

[User Guide] Building standalone Unreal Engine 4 for internal distrubution (Win64, Linux).

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [User Guide] Building standalone Unreal Engine 4 for internal distrubution (Win64, Linux).

    How to make a standalone UE4 build that is capable of building dedicated servers.
    1. Clone UE4 from GitHub (if it shows 404 go to your 'Personal' settings and set your GitHub username)
    Its highly recommended to place near the root of the drive, or in its subfolder (eg. D:\B\), as UBT+clang combo is sensitive to path length.
    2.[Linux support] Download Clang for your version of the engine
    https://wiki.unrealengine.com/Compil..._the_toolchain
    3.[Linux support] Place Clang somewhere near to root and set required environmental variables.
    Code:
        
    LINUX_MULTIARCH_ROOT %PATH_TO_CLANG% (e.g. C:\clang\v9_clang-4.0.0-centos7)
    LINUX_ROOT %PATH_TO_CLANG%\x86_64-unknown-linux-gnu
    UE4_LINUX_USE_LIBCXX 1
    4. To make your engine compatible with official distrubution: open file Build.version from '\Engine\Build' and set Changelist to be the same number as CompatibleChangelist, or copy this file from the official distribution of the engine. Add empty 'BuildId' string. Example of Build.version: Build.version.txt
    Open Version.h, located in 'Engine\Source\Runtime\Launch\Resources' and set the same values as in build.version. Example of Version.h Version.h
    5. Generate project and build it once in Development Win64 configuration. (Mainly to get Unreal Build Tools, etc)
    You can skip this step and copy .net tools from existing engine build if you have one.
    6. Place InstalledEngineBuild.xml in "Engine\Build" folder.
    InstalledEngineBuild.xml.txt
    rename to (InstalledEngineBuild.xml)
    7. Make standalone build of the engine using this tool (thanks ryanjon2040)
    https://forums.unrealengine.com/deve...-for-your-team
    Example config: Win64+Linux+Enable Symbol Store
    8. Wait until build is complete
    9. [Linux support] Run commands from engine's root (from the one you got from git)
    Code:
    robocopy ./Engine ./LocalBuilds/Engine/Windows/Engine *.a /S
    robocopy ./Engine/Source/ThirdParty/Linux ./LocalBuilds/Engine/Windows/Engine/Source/ThirdParty/Linux *.* /S
    It will collect all Linux binaries, and libcxx, that are required by Clang to Archcopy folder while maintaining folder hierarchy.
    *TODO: move this and below steps to InstalledEngineBuild.xml
    10. ...
    11.Profit!

    Distributing and installing the resulting standalone engine in system.
    Copy clang (v10_clang-5.0.0-centos7 for 4.18) to engine root and rename folder to Clang.
    Keep in mind that this built should be placed near the root of the drive, or in its subfolder (eg. D:\B\), as UBT+clang combo is sensitive to path length.

    Create .bat file, containing this script:
    Code:
    set EnginePath=%~dp0
    set EnginePath=%EnginePath:~0,-1%
    net session >nul 2>&1
    if %ERRORLEVEL% equ 0 (
        echo User has enough privileges. Installing...
        reg add "HKEY_CURRENT_USER\SOFTWARE\Epic Games\Unreal Engine\Builds" /v "4.18-Custom" /t REG_SZ /d "%EnginePath%" /f
        echo Adding environmental variables...
        echo LINUX_MULTIARCH_ROOT
        setx /m LINUX_MULTIARCH_ROOT "%EnginePath%\Clang"
        echo LINUX_ROOT
        setx /m LINUX_ROOT "%EnginePath%\Clang\x86_64-unknown-linux-gnu"
        echo UE4_LINUX_USE_LIBCXX
        setx /m UE4_LINUX_USE_LIBCXX "1"
        echo Engine successfully installed.
    ) else (
        echo Please run this script under admin rights.
    )
    Pause
    Now if you set engine to 4.18-Custom in .uproject file it will open up your engine.

    How properly bind OnlineSubsystemSteam to your Linux Dedicated Server.
    This post assumes that you already configured steam, and tried it on windows server.
    If not, read this article
    https://docs.unrealengine.com/latest.../Online/Steam/

    Okay. After building a project server it will work, you can connect to server with OnlineSubsystemNull. But OnlineSubsystemSteam will fail, because it requires some changes to the source.
    To fix this problem, copy OnlineSubsystemSteam from engine folder to your project and add server check to "static void DeleteSteamAppIdFromDisk() in OnlineSubsystemSteam.cpp.
    Code:
    #if UE_SERVER
        const FString SteamAppIdFilename = GetSteamAppIdFilename();
        // Turn off sandbox temporarily to make sure file is where it's always expected
        FScopeSandboxContext ScopedSandbox(false);
        if (FPaths::FileExists(*SteamAppIdFilename))
        {
            bool bSuccessfullyDeleted = IFileManager::Get().Delete(*SteamAppIdFilename);
        }
    #endif // UE_SERVER
    Build of dedicated server in release mode relies on code changes in ConfigureSteamInitDevOptions
    Code:
    // Always check against the Steam client when shipping
    RequireRelaunch = true;
    // Enter shipping app id here
    RelaunchAppId = *you steam_appid here*;
    Also you should copy steamclient.so from steamcmd to your server's binaries location.
    To get instructions for steamcmd visit https://developer.valvesoftware.com/wiki/SteamCMD:ru
    You could obtain 64-bit steamclient.so after launching steamcmd.sh on Linux machine.

    After those manipulations you most likely would be able to run your LinuxServer with steam just fine.

    How to package your game from Windows Batch file.

    Change the script below for your needs
    Code:
    set UE4=*Path to UE4*
    set GameClient="Path to .uproject"
    set GameOutput="Output path"
    set ConfigClient="Shipping / Development"
    set PlatformClient="Win32 / Win64 / Linux / ..."
    set Maps="Map1+Map2+Map3"
    
    cls
    echo UE4: %UE4%
    echo Project: %GameClient%
    echo Output: %GameOutput%
    echo Client Build in progress!
    %UE4%\Engine\Binaries\DotNET\AutomationTool.exe -ScriptsForProject=%GameClient% BuildCookRun -project=%GameClient% -noP4 -clientconfig=%ConfigClient% -serverconfig=%ConfigClient% -nocompile -nocompileeditor -installed -ue4exe=UE4Editor-Cmd.exe -utf8output -platform=%PlatformClient% -build -cook -map=%Maps% -encryptinifiles -pak -createreleaseversion= -manifests -compressed -stage -package -cmdline=" -Messaging" -addcmdline="-SessionId=360EAEA94B14AF6FC8BE7085199EE977 -SessionOwner='BatchBuild' -SessionName='ClientShipping'" -archive -archivedirectory=%GameOutput% >ClientBuild.log
    Attached Files
    Last edited by ortroll; 01-26-2018, 06:24 AM.

    #2
    It definitely should work. Maybe you'll have more success actually building the server on linux, in a VM?

    Comment


      #3
      The server itself is operating properly, I have a problem to make it work with steam.
      btw Iā€‹ā€‹ā€‹ already tried to build server on Ubuntu, but it was not suited for my purposes, since I need a server that is compatible with RHEL/CENTOS/AMAZON Linux. Those distros contain old versions of libs, and require a lot of trickery to build UE4 and it's projects.
      Last edited by ortroll; 12-09-2017, 06:03 PM.

      Comment


        #4
        Ok. The issue was in OnlineSubsystemSteam plugin. Im not quite sure that my solution to this issue is the best, but it might help.
        Build of dedicated server in development mode removes steam_appid file after first launch.
        To fix this problem, copy OnlineSubsystemSteam from engine folder to your project and add server check to "static void DeleteSteamAppIdFromDisk().
        Code:
        #if UE_SERVER
            const FString SteamAppIdFilename = GetSteamAppIdFilename();
            // Turn off sandbox temporarily to make sure file is where it's always expected
            FScopeSandboxContext ScopedSandbox(false);
            if (FPaths::FileExists(*SteamAppIdFilename))
            {
                bool bSuccessfullyDeleted = IFileManager::Get().Delete(*SteamAppIdFilename);
            }
        #endif // UE_SERVER
        Build of dedicated server in release mode relies on code changes in ConfigureSteamInitDevOptions
        Code:
        // Always check against the Steam client when shipping
        RequireRelaunch = true;
        // Enter shipping app id here
        RelaunchAppId = *you steam_appid here*;
        After those manipulations I was able to run my server with steam just fine.
        Also you should copy steamclient.so from steamcmd to your server's binaries location.
        Last edited by ortroll; 12-11-2017, 04:46 AM.

        Comment


          #5
          I'm wondering, what is the purpose of deleting that file? Wouldn't it break your server?

          Comment


            #6
            Originally posted by Zeblote View Post
            I'm wondering, what is the purpose of deleting that file? Wouldn't it break your server?
            Plugin first creates the file, taking values from config, then deletes it, for cleanup purposes I suppose.
            I tested servers behavior on both platforms in development mode. On Windows it indeed breaks your server, as it fails to recreate the file upon next launch (OS: Windows Server 2012). On Linux it successfully creates and deletes the file. In release mode both fail.

            Also I was skimming through answers to find if people were having same issues, so that's not a Linux problem really.
            https://answers.unrealengine.com/que...ing-steam.html

            The steam_appid.txt file is only required for Shipping builds that are not run through Steam, so it's really only a development thing. This isn't intended to be released with the game; after properly uploading and instrumenting your build through Valve AND launching from the Steam client, the text file is no longer necessary. The Valve SDK site might have more information on why it's necessary for development. Oh, and it is required when distributing dedicated server builds.
            Last edited by ortroll; 12-12-2017, 02:27 AM.

            Comment


              #7
              Updated user guide for 4.18

              Comment

              Working...
              X