Static ExecutablesΒΆ
You can produce cross-compiled static executable with dk Exe YourModule.Name where YourModule.Name is the name of your module.
Linking goes through each layer of object files, top to bottom. Any unresolved symbols must be resolved in a layer below it. Only symbols that are needed by the main() function are included in your final executable.
| Layer | Asset | Description | Generating Project |
|---|---|---|---|
| Bytecode objects | ocamlc generated .bc file, converted to multiple object files. | Your project | |
| Bytecode runtime | dksdk-foundations/<TARGET>-{d,r}/{lib}foundation-databases-<TARGET>-{debug,release}.{a,lib} | The OCaml runtime and DkSDK-specific replacements and extensions of the OCaml runtime | dksdk-foundations |
| C packages | dksdk-c-packages/<TARGET>/runtime_static.zip | Third-party C libraries | dksdk-c-packages |
| dksdk_os | dksdk-os/<TARGET>/os.zip | DkSDK Memory Allocation and Logging | dksdk-ffi-c |
| sysroot | dksdk-os/<TARGET>/sysroot[-api<ANDROID_API_LEVEL>].zip | System Libraries like the C runtime library | dksdk-ffi-c |
LayersΒΆ
sysroot layerΒΆ
| Operating System | Sysroot Provenance | Licenses Required | Packages | Libraries |
|---|---|---|---|---|
| Linux | Debian dpkg-cross |
|
| |
| Android | ./dk dksdk.android.ndk.download | Android Software Development Kit License Agreement | Android NDK r23b API 21 | libc - Android Bionic C library. |
| macOS | must be macOS machine | Xcode and Apple SDKs Agreement | ||
| Windows | xwin | MICROSOFT VISUAL C++ 2015 - 2022 RUNTIME | Crypt32, Normaliz |
dksdk_os layerΒΆ
The libraries in the dksdk_os layer provide the implementation of the C headers:
dksdk_os/mem.hdksdk_os/align.hdksdk_os/err.hdksdk_os/logger.hdksdk_os/loggerconf.h
C packages layerΒΆ
The following C package static libraries are created with vcpkg or cmake:
ssl- Linux only. OpenSSL for curl.crypto- Linux only. OpenSSL for curl.nghttp2- HTTP/2.z- zlib. Compression for curl.zstd- Compression for curl.brotlidec- Compression for curl.brotlicommon- Compression for curl.cares- c-ares. Asynchronous DNS resolver.
Bytecode runtime layerΒΆ
This layer is the set of object files for:
- The conventional "INRIA" OCaml bytecode runtime, minus any objects in the DkSDK runtime below. The INRIA bytecode libraries are:
libcamlrunlibunixlibthreadslibcamlstr
- The DkSDK runtime which includes:
- static libraries for
curl,sqlite3andev - static libraries for stubs between OCaml packages and C:
xdgctypessqlite3curlintegersspawnshexpbaseposixattiny_httpdmtimecstructptimebigstringaflwtcheckseumstdintdigestifmirage-cryptoMlFront_ZipFileterminal
- the DkSDK FFI OCaml static library
- a static library "bytemain" containing:
- the
main()C function - DkSDK startup objects
- DkSDK replacements for symbols that are incompatible with static executables:
sqlite3_enable_load_extension
- DkSDK replacement for OCaml callbacks (source available alongside the asset)
- DkSDK replacement for bytecode interpreter (source available alongside the asset)
- the
- static libraries for
Bytecode objects layerΒΆ
The object files are a product of the following steps:
- The traditional OCaml
.bcbytecode file is compiled withocamlcfrom the source code of your project. dkuses the LLVM Machine Code project to create several object files from the.bcbytecode file.

