How to build from command line

I am new to UE and having trouble building a plugin.

I can’t get VS code to build the plugin, so can I compile from the command line?

Perhaps something like this?

cd $UE5_ROOT/Engine/Build/BatchFiles/Linux
./Build.sh Development Linux -Project=<path to plugin.uproject> -TargetType=Editor -Progress -NoHotReloadFromIDE

The above command is running, but it is taking a very long time. Is this rebuilding all of UE5, or just the plugin?

The plugin source code is located outside the UE5_ROOT directory. Is that OK?

Notes:

  • I built UE 5.4 from source.
  • Platform: Fedora 39 linux

Hey @SJJ_1

have a look at this tutorial:

your command builds the project. You can also run the CleanProject.sh file and restart the building with a “fresh” project.

Hello,
Certainly! To compile a plugin from the command line in Unreal Engine (UE), you can use the RunUAT.bat script. Here’s how:

Navigate to the Engine Directory:
Open a terminal and go to your UE5 engine directory (where the Engine folder is located).
Run the Command:
Use the following command to build the plugin:
RunUAT.bat BuildPlugin -plugin=“” -package=“”
Replace with the actual path to your plugin’s .uplugin file. Replace with a folder where the newly compiled plugin will be output.
Plugin Source Location:
It’s okay if your plugin source code is located outside the UE5 root directory.
Remember to adjust the paths accordingly, and this command should build your plugin without rebuilding all of UE.
Best Regards
esther598

Thanks for the info @esther598

The example command I had in my question (using Build.sh) successfully finished (even though it may have done the wrong thing). However when I ran the command you suggested (using RunUAT.sh) it failed with a message about name clashes:

$UE5_ROOT/Engine/Plugins/Experimental/UserToolBoxBasicCommand/Source/UserToolBoxBasicCommand/Public/EngineCommand.h(12): Error: Class 'UEngineCommand' shares engine name 'EngineCommand' with struct 'FEngineCommand' in $PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/FDMTypes.h(140)

I tried changing the name of the FEngineCommand struct to avoid the name clash, but another error then appeared:
$PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/FDMTypes.h(28): Error: An explicit Category specifier is required for any property exposed to the editor or Blueprints in an Engine module.

Given that the build finished OK when using Build.sh, do you think the problem is how I am running RunUAT.sh (and not a problem with the plugin code)?

Full log (before the struct name was changed):

$UE5_ROOT/Engine/Build/BatchFiles> ./RunUAT.sh BuildPlugin -plugin=$JSBSIM_ROOT/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/JSBSimFlightDynamicsModel.uplugin -package=$PLUGIN_BUILD 2>&1 | tee /tmp/build.log.2

Running AutomationTool...

Setting up bundled DotNet SDK
find: ‘../Restricted/**/Source/Programs/Shared’: No such file or directory
find: ‘../Platforms/*/Source/Programs/Shared’: No such file or directory
find: ‘../Restricted/**/Source/Programs/UnrealBuildTool’: No such file or directory
find: ‘../Restricted/**/Source/Programs/AutomationTool’: No such file or directory
AutomationTool.dll is up to date
Start UAT Interactively: dotnet AutomationTool.dll BuildPlugin -plugin=$PLUGIN_SRC/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/JSBSimFlightDynamicsModel.uplugin -package=$PLUGIN_BUILD
$UE5_ROOT/Engine/Binaries/ThirdParty/DotNet/6.0.302/linux/dotnet
Starting AutomationTool...
Parsing command line: BuildPlugin -plugin=$PLUGIN_SRC/UnrealEngine/Plugins/JSBSimFlightDynamicsModel/JSBSimFlightDynamicsModel.uplugin -package=$PLUGIN_BUILD
Initializing script modules...
Total script module initialization time: 0.23 s.
Using $UE5_ROOT/Engine/Binaries/ThirdParty/DotNet/6.0.302/linux/dotnet
Executing commands...
Copying 575 file(s) using max 64 thread(s)
Reading plugin from $PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/JSBSimFlightDynamicsModel.uplugin...
Building plugin for host platforms: Linux
Running: $UE5_ROOT/Engine/Binaries/ThirdParty/DotNet/6.0.302/linux/dotnet "$UE5_ROOT/Engine/Binaries/DotNET/UnrealBuildTool/UnrealBuildTool.dll" UnrealEditor Linux Development -Project="$PLUGIN_BUILD/HostProject/HostProject.uproject" -plugin="$PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/JSBSimFlightDynamicsModel.uplugin" -noubtmakefiles -manifest="$PLUGIN_BUILD/HostProject/Saved/Manifest-UnrealEditor-Linux-Development.xml" -nohotreload -log="$LOG_DIR/Unreal Engine/LocalBuildLogs/UBA-UnrealEditor-Linux-Development.txt"
Log file: $LOG_DIR/Unreal Engine/LocalBuildLogs/UBA-UnrealEditor-Linux-Development.txt
Using 'git status' to determine working set for adaptive non-unity build ($UE5_ROOT).
JSBSim Path Check OK: $PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Lib/Linux/libJSBSim.so
Parsing headers for UnrealEditor
  Running Internal UnrealHeaderTool $PLUGIN_BUILD/HostProject/HostProject.uproject $PLUGIN_BUILD/HostProject/Intermediate/Build/Linux/UnrealEditor/Development/UnrealEditor.uhtmanifest -WarningsAsErrors
$UE5_ROOT/Engine/Plugins/Experimental/UserToolBoxBasicCommand/Source/UserToolBoxBasicCommand/Public/EngineCommand.h(12): Error: Class 'UEngineCommand' shares engine name 'EngineCommand' with struct 'FEngineCommand' in $PLUGIN_BUILD/HostProject/Plugins/JSBSimFlightDynamicsModel/Source/JSBSimFlightDynamicsModel/Public/FDMTypes.h(140)
Total of 0 written
Total execution time: 6.54 seconds
Took 6.67s to run dotnet, ExitCode=6
UnrealBuildTool failed. See log for more details. ($LOG_DIR/Unreal Engine/LocalBuildLogs/UBA-UnrealEditor-Linux-Development.txt)
AutomationTool executed for 0h 0m 7s
AutomationTool exiting with ExitCode=6 (6)
RunUAT ERROR: AutomationTool was unable to run successfully. Exited with code: 6