⚠️ Development Fork NoticeThis is a development fork for contributing improvements to the upstream KBEngine project.
- Branch:
devcontains active development work- Branch:
mastertracks upstreamkbengine/kbengineFor production use, please use the official repository:
- Official: https://github.com/kbengine/kbengine
- Releases: https://github.com/kbengine/kbengine/releases
- Documentation: https://kbengine.github.io/docs/
This fork does NOT provide stable releases or downloads.
https://kbengine.github.io/
Sources : https://github.com/kbengine/kbengine/releases/latest
Unity3d : https://github.com/kbengine/kbengine_unity3d_demo/releases/latest
Unity3d : https://github.com/kbengine/kbengine_unity3d_warring/releases/latest
UE4 : https://github.com/kbengine/kbengine_ue4_demo/releases/latest
Ogre : https://github.com/kbengine/kbengine_ogre_demo/releases/latest
Cocos2d_js : https://github.com/kbengine/kbengine_cocos2d_js_demo/releases/latest
Godot Engine : https://github.com/krogank9/kbe_godot_demo/releases/latest
Docs : https://kbengine.github.io/docs/
API : https://github.com/kbengine/kbengine/tree/master/docs
Email : kbesrv?gmail.com
QQ : 3603661
Maillist : https://groups.google.com/d/forum/kbengine_maillist
https://www.youtube.com/watch?v=sWtk3CfxyGY
http://v.youku.com/v_show/id_XMjgyMjM0MTYwNA==.html?spm=a2h3j.8428770.3416059.1
Execute:
new_assets.bat
Output:
server_assets
## CMake and vcpkg
The CMake build now supports vcpkg manifest mode.
When configured with the vcpkg toolchain, KBEngine will prefer vcpkg-provided fmt, zlib, OpenSSL, libmariadb, hiredis and GTest.
If vcpkg is not active, the current vendored/fallback path remains available.
The manifest is pinned with a vcpkg builtin baseline for reproducible dependency resolution.
Versions are resolved from that baseline (`vcpkg.json` `builtin-baseline`), not from in-repo overrides;
`vcpkg.json` declares the ports (apr, apr-util, curl, fmt, gtest, hiredis, libmariadb, openssl,
python3, tinyxml2, utfcpp, zlib) without pinning exact versions.
libmariadb is the MariaDB Connector/C client library used by KBEngine.
It is suitable for MariaDB and MySQL deployments, including MySQL 8 authentication flows introduced after older 3.0.x connector releases.
Example:
export VCPKG_ROOT=/path/to/vcpkg
cmake --preset vcpkg
cmake --build --preset vcpkg
ctest --preset vcpkg
KBEngine uses CMake 3.21+ for cross-platform building. The build system supports two modes:
- vcpkg mode (Recommended): Uses vcpkg for dependency management
- Fallback mode: Uses vendored dependencies
Common Requirements:
- CMake 3.21 or higher
- C++17 compatible compiler
Platform-Specific:
- Windows: Visual Studio 2019/2022 with C++ development tools
- Linux: GCC 8+ or Clang 10+
- macOS: Xcode 13+ or Clang 10+
Dependencies:
- All dependencies are managed by vcpkg when using vcpkg mode; fallback mode uses vendored sources (system packages are used for optional extras only)
- This includes Python 3, which is embedded into KBEngine (requires Python headers for compilation)
- Libraries with vendored source code include tinyxml2 (XML parsing), tmxparser (map parser), and g3dlite (3D math library)
# 1. Set VCPKG_ROOT environment variable
$env:VCPKG_ROOT = "D:\path\to\vcpkg"
# 2. Configure CMake
cmake --preset vcpkg
# 3. Build
cmake --build build/presets/vcpkg --parallel
# 4. Run tests (optional)
ctest --preset vcpkg --output-on-failureOr use the provided build script:
REM Modify build.bat to match your Visual Studio path
build.bat# 1. Set VCPKG_ROOT
export VCPKG_ROOT=/path/to/vcpkg
# 2. Configure CMake
cmake --preset vcpkg
# 3. Build
cmake --build build/presets/vcpkg --parallel
# 4. Run tests (optional)
ctest --preset vcpkg --output-on-failure# 1. Set VCPKG_ROOT
export VCPKG_ROOT=/path/to/vcpkg
# 2. Configure CMake
cmake --preset vcpkg
# 3. Build
cmake --build build/presets/vcpkg --parallel
# 4. Run tests (optional)
ctest --preset vcpkg --output-on-failureKey Differences:
- Generator: Uses Ninja by default (via CMake presets)
- Runtime Library: Uses DLL runtime (
/MDor/MDd) - Compiler: MSVC with UTF-8 support enabled (
/utf-8) - Path Handling: Windows paths use backslashes
Important Notes:
- Must run from x64 Native Tools Command Prompt or setup environment via script
- Visual Studio 2019/2022 required
- VCPKG_ROOT must be set before configuring
- Build output:
kbe\bin\server\
Troubleshooting:
REM If CMake can't find Visual Studio
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
REM If vcpkg dependencies fail
vcpkg install fmt:x64-windows openssl:x64-windowsKey Differences:
- Generator: Uses Ninja (preferred) or Unix Makefiles
- Compiler Flags: Uses GCC/Clang flags for coverage and optimization
- Runtime: Static linking by default
- Dependencies: May need system packages installed
System Dependencies:
# Ubuntu/Debian
sudo apt-get install build-essential cmake ninja-build
# Fedora/RHEL
sudo dnf install gcc-c++ cmake ninja-build
# Arch Linux
sudo pacman -S base-devel cmake ninjaImportant Notes:
- Use
ninjafor faster builds (automatically used by presets) - Build output:
kbe/bin/server/ - May need to set
LD_LIBRARY_PATHfor runtime dependencies
Key Differences:
- Compiler: Clang from Xcode Command Line Tools
- Frameworks: Uses macOS frameworks instead of Linux libraries
- Universal Binary: Can build for x86_64, arm64, or universal
- Code Signing: May require for distribution
System Requirements:
# Install Xcode Command Line Tools
xcode-select --install
# Or install full Xcode from App Store
# Install Homebrew for additional dependencies
brew install cmake ninja python3Architecture-Specific Builds:
# Apple Silicon (M1/M2/M3)
cmake --preset vcpkg -DCMAKE_OSX_ARCHITECTURES=arm64
# Intel Mac
cmake --preset vcpkg -DCMAKE_OSX_ARCHITECTURES=x86_64
# Universal Binary (both architectures)
cmake --preset vcpkg -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"Important Notes:
- macOS 11 (Big Sur) or later recommended
- Build output:
kbe/bin/server/ - May need to adjust SDK version for older macOS support
cmake --preset vcpkg -DCMAKE_BUILD_TYPE=Debugcmake --preset vcpkg -DCMAKE_BUILD_TYPE=Releasecmake --preset vcpkg -DCMAKE_BUILD_TYPE=RelWithDebInfo# Run all tests
ctest --preset vcpkg --output-on-failure
# Run specific test
ctest --preset vcpkg -R <test_name> --verbose
# Run tests with parallel execution
ctest --preset vcpkg --parallel 4The project uses vcpkg manifest mode for dependency management.
Required dependencies (declared in vcpkg.json):
- fmt - Text formatting
- openssl - Cryptography & SSL/TLS
- curl - HTTP client
- zlib - Compression
- gtest - Testing framework
- hiredis - Redis client
- libmariadb - MySQL/MariaDB connector
- python3 - Embedded scripting (KBEngine embeds a Python interpreter)
- tinyxml2 - XML parsing
- utfcpp - UTF-8 string handling
- apr / apr-util - Apache Portable Runtime
Optional dependencies (off by default, not in the manifest):
- log4cxx - Logging, opt-in via
-DKBE_USE_LOG4CXX=ON(cmake/KBEngineOptions.cmake) - jemalloc - Memory allocator, opt-in via
-DKBE_USE_JEMALLOC=ON(cmake/KBEngineOptions.cmake)
Vendored libraries (not in vcpkg):
- tmxparser - Map tile format parser (
kbe/src/lib/dependencies/tmxparser/) - g3dlite - 3D math and geometry library (
kbe/src/lib/dependencies/g3dlite/)
Note: In vcpkg mode, all dependencies must come from vcpkg. The build will fail if any required vcpkg dependency is not found.
Updating dependencies:
# Modify vcpkg.json to change versions
# Then rebuild
cmake --preset vcpkg
cmake --build build/presets/vcpkgAfter successful build:
| Platform | Executables | Libraries |
|---|---|---|
| Windows | kbe\bin\server\ |
kbe\src\libs\ |
| Linux | kbe/bin/server/ |
kbe/src/libs/ |
| macOS | kbe/bin/server/ |
kbe/src/libs/ |
# Clear CMake cache
rm -rf build/presets/vcpkg
# Reconfigure
cmake --preset vcpkg# Clean vcpkg build
vcpkg remove --outdated
# Rebuild dependencies
vcpkg install --recurseWindows:
# Ensure Visual Studio environment is set
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64Linux/macOS:
# Check compiler
gcc --version
clang --version
# Install if missing
# Ubuntu/Debian: sudo apt-get install build-essential
# macOS: xcode-select --install# If CMake cannot find Python3, ensure vcpkg is properly configured
# Python 3 is provided by vcpkg, no system installation needed
cmake --preset vcpkg -DVCPKG_ROOT=/path/to/vcpkgcmake --preset vcpkg -DBUILD_TESTING=OFFcmake --preset vcpkg -DKBE_ENABLE_CODE_COVERAGE=ONcmake --preset vcpkg -DCMAKE_INSTALL_PREFIX=/opt/kbengine- CMake Documentation: https://cmake.org/documentation/
- vcpkg Documentation: https://vcpkg.io/en/
- Upstream Documentation: https://kbengine.github.io/docs/
- Issue Tracker: https://github.com/kbengine/kbengine/issues
- Chinese site: https://kbengine.github.io/cn/
- Discussions: https://github.com/kbengine/kbengine/discussions
- QQ groups: 461368412, 16535321, 716679842
KBEngine is a MMOG game server engine. All game logic is written in Python scripts (with hot reload), and the companion client plug-ins let you build a complete client quickly on top of Unity3D, UE4, OGRE, HTML5, and more.
The engine itself is written in C++, so developers do not have to re-implement the generic low-level server technology - they can spend their effort on the game and ship online games quickly and reliably.
(About capacity: KBEngine's architecture is multi-process, distributed and dynamically load-balanced, so in theory the capacity ceiling keeps rising as hardware is added; a single machine's limit depends on the complexity of the game logic itself.)