Skip to content

Building and Compilation

medoomem edited this page Jul 23, 2026 · 2 revisions

Building & Compilation

This page details the build prerequisites, code generation pipeline, and compilation procedures for Windows (MSVC) and Linux/macOS (GCC/Clang).


System Requirements & Prerequisites

  • C++ Compiler: C++20 compliant compiler (MSVC 2019+, GCC 10+, or Clang 11+).
  • Build System: CMake 3.16 or higher.
  • Scripting Environment: Python 3.x (used for code generation).
  • Optional: pybind11 (required only if building the native import moezip extension module).

Step 1: Code Generation (make.py)

Before running CMake, execute make.py. This script processes words_final.txt and router_stateless_v4.json, chunking them into embedded_assets.hpp and writing out the complete project source files.

Windows CMD:

python make.py

Linux / macOS:

python3 make.py

Note: If words_final.txt or router_stateless_v4.json are absent, make.py uses built-in fallback vocabulary and router defaults.


Step 2: Windows Build (MSVC)

Standard Build (Zero External Python Dependencies)

Builds the standalone CLI executable (moezip.exe) and the shared library (moezip.dll):

cmake -B build
cmake --build build --config Release

PyBind11 Build (Native import moezip Module)

To compile the native Python extension (moezip.pyd), install pybind11 and pass its CMake directory:

pip install pybind11

for /f "delims=" %i in ('python -c "import pybind11; print(pybind11.get_cmake_dir())"') do for /f "delims=" %j in ('python -c "import sys; print(sys.executable)"') do cmake -B build -Dpybind11_DIR="%i" -DPYTHON_EXECUTABLE="%j"

cmake --build build --config Release

Output Artifacts (build/Release/)

build/Release/
├── moezip.exe     # Standalone Command Line Executable
├── moezip.dll     # Dynamic Link Library (C-API Exports)
├── moezip.lib     # DLL Import Library
├── moezip.exp     # DLL Export File
└── moezip.pyd     # Native Python Extension Module (if pybind11 enabled)

Step 3: Linux & macOS Build (GCC / Clang)

Standard & PyBind11 Build

On Linux systems with python3-pybind11 installed, CMake automatically detects the library and builds all three targets in parallel:

# Ubuntu / Debian prerequisites
sudo apt-get install build-essential cmake python3-pybind11

# Configure and compile
cmake -B build_linux -DCMAKE_BUILD_TYPE=Release
cmake --build build_linux --parallel

Output Artifacts (build_linux/)

build_linux/
├── moezip         # Standalone CLI Executable
├── libmoezip.so   # C-API Shared Library
└── moezip.so      # Native Python Extension Module

CMake Target Reference

CMakeLists.txt defines three distinct build targets:

Target Name Type Description Primary Output
moezip Executable Standalone CLI tool (main.cpp) moezip.exe / moezip
moezip_dll Shared Library C-API interface (api.cpp) moezip.dll / libmoezip.so
moezip_py Module PyBind11 bindings (bindings.cpp) moezip.pyd / moezip.so

To compile a specific target individually:

# Example: Build only the C-API Shared Library
cmake --build build --config Release --target moezip_dll

Optimization Flags

CMakeLists.txt applies platform-specific Release optimizations automatically:

  • MSVC (Windows): /EHsc /O2 /std:c++20
  • GCC / Clang (Linux/macOS): -O3 -march=native -std=c++20

🗜️ moezip Wiki


📦 Target Artifacts

  • Windows (MSVC):
    • moezip.exe (CLI)
    • moezip.dll (Shared Lib)
    • moezip.pyd (Python)
  • Linux (GCC):
    • moezip (CLI)
    • libmoezip.so (Shared Lib)
    • moezip.so (Python)

🔗 Quick Links

Clone this wiki locally