Guide · Open source
How to use EnTT: install, build and write your first ECS code
Updated · written with AI from the project's own documentation and checked against our catalogue data
EnTT is a header-only C++ library for game programming and other tasks, best known for its entity-component system (ECS), where game objects are plain IDs with attached data components. This guide shows how to get the source, what you need to build it, and how the core registry and view calls fit together in a small example. By the end you will know how to add EnTT to a CMake project and read the basic ECS pattern.
Quick start
- 1Check prerequisites. Confirm you have a C++17 compatible compiler and CMake installed.
- 2Clone the repository. Run git clone https://github.com/skypjack/entt.git to get the source.
- 3Add EnTT to your build. Because EnTT is header-only, make its headers available to your CMake project and include them.
- 4Include the header. Add #include <entt/entt.hpp> at the top of the source file that uses the library.
- 5Create a registry and entities. Declare an entt::registry and call create() to make entities, then emplace() components onto them.
- 6Iterate with a view. Call registry.view<...>() and loop with each() or a range-for to process matching entities.
What is EnTT and who is it for?
The entity-component-system is an architectural pattern used mostly in game development. Entities are IDs, components are plain data attached to them, and systems operate on the components they need.
EnTT is written in modern C++ and is aimed at C++ game developers, simulation builders and engine programmers. It also includes utilities such as a reflection system, signal handlers, a hash map, resource management and an execution graph builder.
- Best for C++ developers who want an ECS or reusable utilities like signals and hash maps.
- Not for those who want a full game engine with editor and rendering, since EnTT is a set of building blocks.
- Not for non-C++ developers.
What do you need before installing EnTT?
The README lists two prerequisites: a C++17 compatible compiler and CMake. Because EnTT is header-only, you include it in your project rather than linking a separate binary.
The latest release has no binaries, so plan to build from source. The README also notes that projects using CMake or a package manager such as vcpkg or Conan fit well.
- A C++17 compatible compiler
- CMake
- Git, to clone the repository
How do you get EnTT and build it?
Clone the repository from GitHub. The README gives this command for that step.
The README also describes an option for benchmarks: set the ENTT_BUILD_BENCHMARK CMake option to ON and compile the benchmark test in release mode so compiler optimisations are enabled.
git clone https://github.com/skypjack/entt.gitHow do you write your first ECS code with EnTT?
The core type is entt::registry. You create entities with create(), attach components with emplace(), and iterate over entities that have a set of components using view(). The README example attaches a position to every entity and a velocity only to even-numbered ones, then updates only the entities that have both.
Views support several styles: a callback with each(), a range-for over each(), or a plain forward iterator where you fetch extra components with get().
- Include <entt/entt.hpp>.
- Create a registry with entt::registry.
- Use registry.create() to make an entity.
- Use registry.emplace<T>(entity, ...) to add a component.
- Use registry.view<...>() to loop over matching entities.
#include <entt/entt.hpp>
struct position {
float x;
float y;
};
struct velocity {
float dx;
float dy;
};
void update(entt::registry ®istry) {
auto view = registry.view<const position, velocity>();
view.each([](const auto &pos, auto &vel) { /* ... */ });
for(auto [entity, pos, vel]: view.each()) {
// ...
}
}
int main() {
entt::registry registry;
for(auto i = 0u; i < 10u; ++i) {
const auto entity = registry.create();
registry.emplace<position>(entity, i * 1.f, i * 1.f);
if(i % 2 == 0) { registry.emplace<velocity>(entity, i * .1f, i * .1f); }
}
update(registry);
}Which other features can you use?
The README's feature list goes beyond ECS. It mentions a built-in runtime reflection system that is non-intrusive and macro-free, delegates and signal handlers with a small event dispatcher, a sparse set based hash map, and resource management covering cache, loaders and handles.
The full API is documented, and the README points to the wiki for more detail.
- Reflection system (runtime, macro-free)
- Signal handlers and a tiny event dispatcher
- Sparse set based hash map
- Resource management: cache, loaders, handles
- Execution graph builder for scheduling
Where can you find documentation and help?
The API docs are generated with Doxygen and linked from the README. The project wiki and its FAQ page cover more topics, and there are Gitter and Discord channels for questions that do not need an issue.
- Documentation: https://skypjack.github.io/entt/
- Wiki: https://github.com/skypjack/entt/wiki
- FAQ: https://github.com/skypjack/entt/wiki/Frequently-Asked-Questions
What people use it for
- Storing positions, velocities and other data for many game objects in a data-oriented ECS.
- Building a simulation where entities are plain IDs and behaviour lives in systems.
- Using signal handlers or the hash map as standalone C++ utilities in a non-game project.
- Loading and caching resources with the resource management tools.
Frequently asked questions
Is EnTT free to use?
EnTT is released under the MIT licence, as listed on the project page. The MIT licence generally permits use in commercial and private projects, but read the licence file in the repository for the exact terms.
What do I need to install EnTT?
The README lists a C++17 compatible compiler and CMake as prerequisites. You clone the repository with git and build from source.
Is EnTT a library or a game engine?
EnTT is a library of building blocks. It does not include an editor or rendering, so developers wanting a full engine out of the box should look elsewhere.
Do I need to compile EnTT into a binary?
EnTT is header-only, so you include its headers in your project instead of linking a separate binary. The latest release has no binaries, so you build from source.
What are alternatives to EnTT?
The README lists EntityX, flecs, entityplus and Unity DOTS as comparable projects. EntityX inspired the EnTT API, according to the README.
Does EnTT work outside game development?
The README describes EnTT as a library for game programming and much more. Its utilities such as signals, hash maps and resource handles are general purpose, but it is written in C++ only.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
EnTT suits C++ developers who want a fast, header-only ECS or reusable utilities like signals and a hash map, and who are comfortable building from source with CMake. If you want a ready-made engine with an editor and rendering, or you do not work in C++, pick a different tool such as Unity DOTS or a full engine.
Install options & downloads