Projects, Modules & Build.cs
An Unreal C++ project is a folder with a .uproject file, some content, and one or more modules of C++ code. Understanding modules early saves hours of "unresolved external symbol" errors later.
The folders
Arena/
├── Arena.uproject JSON: engine version, modules, enabled plugins
├── Config/ DefaultEngine.ini, DefaultGame.ini, DefaultInput.ini …
├── Content/ .uasset and .umap files (binary, edited in the editor)
├── Source/
│ ├── Arena.Target.cs game target (the packaged game)
│ ├── ArenaEditor.Target.cs editor target (what you run while developing)
│ └── Arena/ the "Arena" module
│ ├── Arena.Build.cs module rules: dependencies, include paths
│ ├── Arena.h / Arena.cpp module boilerplate (IMPLEMENT_PRIMARY_GAME_MODULE)
│ ├── Public/ Private/ optional split of headers and sources
│ └── …your classes
├── Plugins/ project plugins, each with its own .uplugin and modules
├── Binaries/ Intermediate/ Saved/ DerivedDataCache/ generated, never commitOnly Config/, Content/, Source/, Plugins/ (minus their generated folders) and the .uproject go into version control.
The .uproject
{
"FileVersion": 3,
"EngineAssociation": "5.5",
"Category": "",
"Description": "",
"Modules": [
{ "Name": "Arena", "Type": "Runtime", "LoadingPhase": "Default",
"AdditionalDependencies": [ "Engine" ] }
],
"Plugins": [
{ "Name": "EnhancedInput", "Enabled": true },
{ "Name": "GameplayAbilities", "Enabled": true },
{ "Name": "StateTree", "Enabled": true }
]
}Enabling a plugin in Edit → Plugins writes it here. Some plugins (Enhanced Input) are enabled by default in recent versions; listing them explicitly does no harm.
Modules and Build.cs
A module is the unit of compilation and linking. Each module becomes one DLL in editor builds (UnrealEditor-Arena.dll) and is linked into the executable in monolithic packaged builds. The engine itself is hundreds of modules: Core, CoreUObject, Engine, EnhancedInput, AIModule, GameplayAbilities, UMG…
A module's *.Build.cs is a C# class that tells UnrealBuildTool what the module depends on:
// Source/Arena/Arena.Build.cs
using UnrealBuildTool;
public class Arena : ModuleRules
{
public Arena(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput"
});
PrivateDependencyModuleNames.AddRange(new string[]
{
"AIModule", "NavigationSystem", "GameplayTasks", // AI
"GameplayAbilities", "GameplayTags", // GAS
"UMG", "Slate", "SlateCore" // UI
});
}
}- Public dependencies: your public headers include headers from that module, so anyone who depends on you needs it too.
- Private dependencies: only your
.cppfiles use it.
When you include "AIController.h" and get unresolved external symbol at link time, or cannot open include file at compile time, the fix is almost always a missing module name here. The engine's API reference page for every class lists its Module and Header at the bottom: that is the name to add.
Note: A plugin needs two things: enabled in the
.uproject(so the editor loads it) and listed inBuild.cs(so your C++ can link against its modules). Forgetting the second gives link errors; forgetting the first gives a runtime crash or a "module not found" dialog.
Targets
// Source/ArenaEditor.Target.cs
using UnrealBuildTool;
public class ArenaEditorTarget : TargetRules
{
public ArenaEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.Latest;
IncludeOrderVersion = EngineIncludeOrderVersion.Latest;
ExtraModuleNames.Add("Arena");
}
}Type is Game, Editor, Client, Server or Program. A Server target builds a dedicated server (and needs a source-built engine).
Module boilerplate
// Source/Arena/Arena.cpp
#include "Arena.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, Arena, "Arena");Each class you export from the module is marked with the module's API macro, ARENA_API, generated from the module name. Without it, other modules (including a second module of your own game) can't link against the class.
Splitting a game into modules
Small games keep one module. Larger ones split, for faster iteration and cleaner dependencies: ArenaCore (types, interfaces), ArenaGameplay, ArenaUI, ArenaEditor (editor-only tools, Type: "Editor"). The rule that keeps this sane: dependencies only point one way. UnrealBuildTool rejects some cycles outright and warns about others.
The model below checks a dependency graph for cycles with a depth-first search, which is the check you want to pass before adding a new Build.cs dependency.
#include <iostream>
#include <map>
#include <string>
#include <vector>
using Graph = std::map<std::string, std::vector<std::string>>;
bool visit(const Graph& g, const std::string& m, std::map<std::string, int>& state, std::vector<std::string>& path) {
state[m] = 1; // 1 = on the current path, 2 = finished
path.push_back(m);
auto it = g.find(m);
if (it != g.end())
for (const auto& dep : it->second) {
if (state[dep] == 1) { // back edge: a cycle
std::cout << "cycle: ";
for (const auto& p : path) std::cout << p << " -> ";
std::cout << dep << "\n";
return true;
}
if (state[dep] == 0 && visit(g, dep, state, path)) return true;
}
path.pop_back();
state[m] = 2;
return false;
}
void check(const char* label, const Graph& g) {
std::map<std::string, int> state;
std::vector<std::string> path;
std::cout << label << ": ";
for (const auto& [m, deps] : g)
if (state[m] == 0 && visit(g, m, state, path)) return;
std::cout << "no cycles\n";
}
int main() {
Graph ok = {{"ArenaUI", {"ArenaGameplay", "UMG"}}, {"ArenaGameplay", {"ArenaCore", "AIModule"}},
{"ArenaCore", {"Engine"}}, {"Engine", {"Core"}}};
check("layered", ok);
Graph bad = ok;
bad["ArenaGameplay"].push_back("ArenaUI"); // gameplay now includes a UI header
check("after a shortcut", bad);
}layered: no cycles
after a shortcut: cycle: ArenaGameplay -> ArenaUI -> ArenaGameplay
The usual fix for that cycle: gameplay broadcasts a delegate or an event (next lessons), and the UI module subscribes. Gameplay never needs to know the UI exists.
Test yourself
You include AIController.h and get unresolved external symbols at link time. What is the most likely fix?
- Restart the editor
- Add "AIModule" to the module's dependency list in Build.cs
- Add the header to the .uproject
- Mark the class with UCLASS
When should a dependency be Public rather than Private?
- Always
- When your public headers include that module's headers
- When the module is a plugin
- When it is an engine module
Which folders should NOT be committed?
- Config and Content
- Source and Plugins
- Binaries, Intermediate, Saved and DerivedDataCache
- The .uproject