Install and Compile
The install process¶
When you run kp install, KnitPkg performs (conceptually) the following steps:
- Reads registry metadata to resolve dependency versions.
- Downloads dependency sources (for example, the
calcproject) into.knitpkg/cache. - Processes the entrypoint and detects
@knitpkg:includedirectives, which reference external headers coming from dependencies. - Generates the file
knitpkg/flat/KnitPkgSMA_flat.mqh.
See below how the terminal looks like after you run kp install:

Inside knitpkg/flat/KnitPkgSMA_flat.mqh we have the SMA function and the class TimeSeriesArray used by the indicator:
As we can see, that generated file is a “flattened” (flat) header that contains all the dependency code the indicator needs. After it exists, the main file src/KnitPkgSMA.mq5 can include it and compilation works normally. What if we try kp compile?

Voilá—thanks to KnitPkg, the project compiles all the sources declared in the manifest compile entry and the indicator is ready to use!
About the compiler
kp compile calls the standard MetaEditor compiler from the command line. You can still compile normally from the MetaEditor IDE if you prefer.
The nice extra: by default, kp compile moves the generated binary into the bin/ directory, keeping compiled artifacts and source files neatly separated. Try kp compile --help for other options.
Lock files and reproducible builds¶
By default, every time you run kp install, KnitPkg queries the registry for each dependency and resolves the latest version that satisfies the configured version ranges. The exact version selected for each dependency is then written to the lock file: knitpkg/lock.json.
This lock file is what makes installs deterministic across machines and across time.
Installing with the lock file (--locked)¶
For reproducible builds, use:
When --locked is used, KnitPkg installs the exact versions recorded in knitpkg/lock.json, regardless of:
- the version ranges declared in knitpkg.yaml, or
- newer versions of any dependency being published later.
Reproducible builds
KnitPkg guarantees reproducible builds as long as you keep the lock file and install with kp install --locked.