README 未给出包管理器或 CMake 安装命令,需自行将源码集成进构建;C++ 用户需 C++17 编译器;语言绑定由社区维护,可能未跟进 master 最新提交

git clone https://github.com/SanderMertens/flecs.gitREADME 未说明显存或 GPU 要求;纯 C/C++ 库,可跨平台编译,并可用 emscripten 在浏览器中运行
轻量零依赖的 C/C++ ECS 框架,用实体组件系统支撑百万级实体的游戏与仿真
用 C/C++ 写的高性能实体组件系统(ECS),面向数据导向设计,帮游戏和引擎开发者把对象逻辑拆成实体与组件,跑得更快、扩展更顺。
核心能力
- 提供零依赖 C99 API 与不使用 STL 容器的 C++17 类型安全 API
- 首个完整支持实体关系的开源 ECS,原生支持层级与预制体
- 采用缓存友好的 archetype/SoA 存储,每帧可处理百万级实体
- 用无锁调度器在多 CPU 核心上并行运行系统
- 内置反射框架、JSON 序列化与带 join 的查询语言
容易踩的坑
- v4.2.0Flecs v4.2.0最新正式版2026-11-04 · 2026-11-04 05:48 UTC
Release announcement
https://ajmmertens.medium.com/flecs-4-2-is-out-09435e80fdd1
Release notes
This version includes the following improvements:
- [core] Flush stage commands in ecs_fini
- [core] Detect WebAssembly targets other than Emscripten (thanks @andrewgazelka!)
- [core] Default to Any term for observers without terms
- [core] Rename (OnInstantiate, Override) trait to (OnInstantiate, Copy)
- [core] Add ecs_ref_from_ptr()
- [core] Lock tables for OnAdd/OnRemove hooks and observers
- [core] Only allow DontFragment With targets on DontFragment components
- [core] Reduce overhead of disabling entities
- [core] Optimize performance and memory usage of table graph storage
- [core] Allow changing components of instantiated prefab by clearing stale IsA edges
- [core] Do not silence warnings in user code
- [core] Add Sparse and DontFragment support to ecs_each_id
- [core] Return empty iterator from ecs_children for Wildcard and Any parents
- [core] Rename ecs_is_deferred to ecs_is_stage
- [script] Warn when a script inherits from Prefab instead of declaring a prefab
- [core] Emit ChildOf events for entities created with ecs_new_w_parent
- [core] Remove implicit defer mode from core
- [core] Implement component inheritance as storage feature
- [core] Allow setting cmp/equals hooks on in-use components
- [core] Copy inherited DontFragment components to instantiated prefab children that have no IsA relationship with the prefab child
- [core] Events only propagate down a subtree when an observer with an up term exists for the id
- [core] Observers skip the query engine for tables that cannot match by type and resolve single up(IsA) terms through the base table
- [core] Skip observer maps that hold only up notify observers when forwarding events
- [core] Create named childr
- v4.1.6Flecs v4.1.62026-06-29 · 2026-06-29 02:09 UTC
查看更新说明
Highlights
- New Data Oriented Hierarchies blog!
- Lots of code hardening with 130 bugfixes and more than 500 new test cases
- New entity range API that correctly handles recycling
- New script features:
// NEW: include statements include assets.flecs // NEW: functions fn color(x: i32, z: i32) -> Rgba { {x, 0, z, 1.0} } for x in 0..10 { for z in 0..10 { "e_{x}_{z}" { // NEW: assign expressions to components directly Rgb: color(x, z).rgb // NEW: swizzle operators } } }-
Multiple inspector panels in the explorer:
-
New entities can now be created from the explorer:
-
New dialog for adding components:
Release notes
This version includes the following improvements:
- [core] Add optimized function for moving small component values across tables
- [core] Improve performance of reparenting for non-fragmenting hierarchies
- [core] Throw error when changing children of already instantiated prefab
- [core] Create default range for already created entities when calling ecs_entity_range_new()
- [core] Throw INVALID_OPERATION assert when parenting to not-alive parent
- [core] Allow for overriding component hooks to support hot reloading
- [core] Reduce the size of ecs_ref_t
- [core] Introduce new update() API for modifying existing systems/observers
- [core] Do not assert when entities have non-unique names
- [core] Always run exclusive access checks when feature is enabled
- [core] Implement new range API that correctly handles recycling
- [core] Allow for specifying offset for ecs_delete_empty_tables() function
- [core] Improve error message when using ecs_field for sparse component
- [cpp] Replace usage of NULL with nullptr in C++ API headers
- [cpp] Replace deprecated std::is_trivial
- [cpp] Implement query group iterator for C++ API
- [[cpp](https://github.com
- v4.1.5Flecs v4.1.52026-03-15 · 2026-03-15 23:45 UTC
查看更新说明
Highlights
- New non-fragmenting hierarchy storage which significantly boosts asset hierarchy performance.
- Reduced binary footprint of C++ component registration
- Lots of hardening bugfixes for issues detected by the AFL fuzzer (1500 new tests since the last release!).
- New math and Perlin noise functions for Flecs Script.
- Added support for vector type operations in Flecs script:
const a = Position: {10, 20} const b = Position: {1, 2} const c: a + b // {a.x + b.x, a.y + b.y}- C++ API improvements:
New function to iterate all entities in the world:
world.each([](flecs::entity e) { // ... });System components can now be deduced from each() arguments:
world.system("Move") .each([](Position& p, const Velocity& v) { // ... });Improved APIs for creating hierarchies:
flecs::entity p = world.entity(world, "p"); // Create child for ChildOf (fragmenting) hierarchy flecs::entity child_a = world.entity(world, p, "a"); // Create child for Parent (non-fragmenting) hierarchy flecs::entity child_b = world.entity(world, flecs::Parent{p}, "b");Release notes
This version includes the following bugfixes:
[core]Fix issue where ref could return wrong value during recursive entity cleanup.[core]Fix issue with deferred calls tomodified()for DontFragment components.[core]Fix issue where it wasn't possible to inherit from entity with Relationship trait.[core]Fix issue with cloning entity symbols.[core]Fix issue with removing sparse pair with recycled target.[core]Fix issue with overriding existing exclusive relationships.[core]Fix issue with combining relationship constraints with component disabling.[core]Return 0 for negative indices inecs_get_target().[core]Fixecs_table_get_target()bounds check to reject negative and >=count indices.[core]Fix issue with deleting sparse component while deferring is suspended.[core]Fix issue with usinghas()/get()from hooks.[core]Fix issue where deferred setting after removing on a prefab instance could fail.[core]Fix issues with sparse components and overriding.[core]Fix race condition in component registration code.[core]Fix assert when toggling component before adding it to any entity.- [
[core]](https://
- v4.1.4Flecs v4.1.42025-12-12 · 2025-12-12 22:18 UTC
查看更新说明
Highlights
- Small release to fix a few bugs that got identified shortly after releasing 4.1.3
Release notes
This version includes the following bugfixes:
[core]Revert change for supporting types with destructive move semantics (caused crash)[core]Fix issues with ordered children trait and nested prefabs[core]Fix issues with ordered children trait and prefab slots[core]Fix assert when reclaiming component record (usingworld.shrink()) for large component id
This version includes the following improvements:
[core]Addecs_get_version()function (thanks @tabdroid-1!)[docs]Correct bazel test example in building flecs manual[docs]Fix documentation forECS_QUERY,ECS_QUERY_DEFINEandecs_querymacros
New Contributors
- @tabdroid-1 made their first contribution in https://github.com/SanderMertens/flecs/pull/1891
Full Changelog: https://github.com/SanderMertens/flecs/compare/v4.1.3...v4.1.4
- v4.1.3Flecs v4.1.32025-12-06 · 2025-12-06 23:49 UTC
查看更新说明
Highlights
- Improved RAM utilization (create fewer component records, reclaim more data from component vectors, smaller entity administration)
- A new Building Flecs manual!
Release notes
This version includes the following bugfixes:
[core]Fix issue with reparenting named ordered children[core]Fix issue withecs_ref_getandecs_shrink[core]Fix issue where order or instantiated prefab children could be wrong[core]Fix assert forDontFragmentrelationship during world cleanup[core]Fix issue with how dtors get called for types that don't support non-destructive moves (thanks @Watermelon914!)[os_api]Add missingWIN32_LEAN_AND_MEANbefore new windows.h include[queries]Fix assert when usingset_varfor query with one cascad term[meta]Fix corruption with deserializing into enum with non-32 bits underlying type
This version includes the following improvements:
[cpp]Allowset_ptrto be used for pairs (thanks @Reddy-dev!)[cpp]Addowns_second()andauto_override_second()methods (thanks @Reddy-dev!)[core]Don't always create(T, *),(*, T)component records (only create when used)[core]Don't create component record when registering trait[core]Don't create component record forChildOf[core]Prevent creation of(*, 0)component record[core]Reclaim component vectors to actual count instead of power of 2[core]Reclaim memory from map data structures onworld.shrink()[core]Reclaim memory from empty component records duringworld.shrink()[core]Remove redundant component record lookup in observable code[core]Add convenience macro's for iterating component records and queries[core]Remve redundantecs_map_params_ttype and functions[core]Remove redundantif (table)check in table cache[core]Remove redundant check on cache initialized inecs_table_cache_get[core]Removeecs_record_t::crfield[core]Increase the maximum size of error strings[core]Prevent modifications to map while iterating[core]Don't callflecs_notify_on_addwhen creating entity in root table[core]Addecs_is_defer_suspended()function[observers]Remove redundant check inflecs_emit[queries]Add traversal tests for(ChildOf, _)[queries]Add performance tracing toecs_query_init[os_api]Useecs_os_free()instead offree()inflecs_dump_backtrace()[stats]Track memory of new locked components map[docs]Add Rescue Ops: Wildfire to README[docs]Renamecustom_runnerexamples torun_callback[docs]Remove outdated references to.singleton()API[docs]Add new "Building Flecs" manual (previously on quickstart)
Breaking changes:
- None
New Contributors
- @Watermelon914 made their first contribution in https://github.com/SanderMertens/flecs/pull/1874
Full Changelog: https://github.com/SanderMertens/flecs/compare/v4.1.2...v4.1.3
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。

Flecs is a fast and lightweight Entity Component System that lets you build games and simulations with millions of entities (join the Discord!). Here are some of the framework's highlights:
- Fast and portable zero dependency C99 API
- Modern type-safe C++17 API that doesn't use STL containers
- First open source ECS with full support for Entity Relationships!
- Fast native support for hierarchies and prefabs
- Code base that builds in less than 5 seconds
- Runs in the browser without modifications with emscripten
- Cache friendly archetype/SoA storage that can process millions of entities every frame
- Automatic component registration that works out of the box across shared libraries/DLLs
- Write free functions with queries or run code automatically in systems
- Run games on multiple CPU cores with a fast lockless scheduler
- Verified on all major compilers and platforms with CI running more than 13000 tests
- Integrated reflection framework with JSON serializer and support for runtime components
- Unit annotations for components
- Powerful query language with support for joins and inheritance
- Statistics addon for profiling ECS performance
- A web-based UI for monitoring & controlling your apps:
To support the project, give it a star 🌟 !
What is an Entity Component System?
ECS is a way of organizing code and data that lets you build games that are larger, more complex and are easier to extend. Something is called an ECS when it:
- Has entities that uniquely identify objects in a game
- Has components which are datatypes that can be added to entities
- Has systems which are functions that run for all entities matching a component query
For more information, check the ECS FAQ!
Show me the code!
C99 example:
typedef struct {
float x, y;
} Position, Velocity;
void Move(ecs_iter_t *it) {
Position *p = ecs_field(it, Position, 0);
Velocity *v = ecs_field(it, Velocity, 1);
for (int i = 0; i < it->count; i++) {
p[i].x += v[i].x;
p[i].y += v[i].y;
}
}
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init();
ECS_COMPONENT(ecs, Position);
ECS_COMPONENT(ecs, Velocity);
ECS_SYSTEM(ecs, Move, EcsOnUpdate, Position, Velocity);
ecs_entity_t e = ecs_insert(ecs,
ecs_value(Position, {10, 20}),
ecs_value(Velocity, {1, 2}));
while (ecs_progress(ecs, 0)) { }
}
Same example in C++:
struct Position {
float x, y;
};
struct Velocity {
float x, y;
};
int main(int argc, char *argv[]) {
flecs::world ecs;
ecs.system<Position, const Velocity>()
.each([](Position& p, const Velocity& v) {
p.x += v.x;
p.y += v.y;
});
auto e = ecs.entity()
.insert([](Position& p, Velocity& v) {
p = {10, 20};
v = {1, 2};
});
while (ecs.progress()) { }
}
Projects using Flecs
If you have a project you'd like to share, let me know on Discord!
Tempest Rising
Territory Control 2
Polyzonia
Resistance is Brutal
Appulse
Rescue Ops: Wildfire
Age of Respair
FEAST
Gloam Vault
Antimatcher
Writ of Battle
Extermination Shock
The Forge
ECS survivors
8402
Tome Tumble Tournament
Sol Survivor
After Sun
Flecs Hub
Flecs Hub is a collection of repositories that show how Flecs can be used to build game systems like input handling, hierarchical transforms and rendering.
| Module | Description |
|---|---|
| flecs.components.cglm | Component registration for cglm (math) types |
| flecs.components.input | Components that describe keyboard and mouse input |
| flecs.components.transform | Components that describe position, rotation and scale |
| flecs.components.physics | Components that describe physics and movement |
| flecs.components.geometry | Components that describe geometry |
| flecs.components.graphics | Components used for computer graphics |
| flecs.components.gui | Components used to describe GUI components |
| flecs.systems.transform | Hierarchical transforms for scene graphs |
| flecs.systems.physics | Systems for moving objects and collision detection |
| flecs.systems.sokol | Sokol-based renderer |
| flecs.game | Generic game systems, like a camera controller |
Language bindings
The following language bindings have been developed with Flecs! Note that these are projects built and maintained by helpful community members, and may not always be up to date with the latest commit from master!
- C#:
- Rust:
- Zig:
- Lua:
- Clojure
- Java


















