Building from Source
Clone
Ensure submodules are also cloned.
git clone --recurse-submodules https://github.com/curtisalexander/readstat-rs.git
The ReadStat repository is included as a git submodule within this repository. In order to build and link, first a readstat-sys crate is created. Then the readstat library and readstat-cli binary crate utilize readstat-sys as a dependency.
Linux
Install developer tools
sudo apt install build-essential clang
Build
cargo build
iconv: Linked dynamically against the system-provided library. On most distributions it is available by default. No explicit link directives are emitted in the build script — the system linker resolves it automatically.
zlib: Linked via the libz-sys crate, which will use the system-provided zlib if available or compile from source as a fallback.
macOS
Install developer tools
xcode-select --install
Build
cargo build
iconv: Linked dynamically against the system-provided library that ships with macOS (via cargo:rustc-link-lib=iconv in the readstat-sys build script). No additional packages need to be installed.
zlib: Linked via the libz-sys crate, which will use the system-provided zlib that ships with macOS.
Windows
Building on Windows requires LLVM and Visual Studio C++ Build tools be downloaded and installed.
In addition, the path to libclang needs to be set in the environment variable LIBCLANG_PATH. If LIBCLANG_PATH is not set, the readstat-sys build script will check the default path C:\Program Files\LLVM\lib and fail with instructions if it does not exist.
For details see the following.
Build
cargo build
iconv: Compiled from source using the vendored libiconv-win-build submodule (located at crates/readstat-iconv-sys/vendor/libiconv-win-build/) via the readstat-iconv-sys crate. readstat-iconv-sys is a Windows-only dependency (gated behind [target.'cfg(windows)'.dependencies] in readstat-sys/Cargo.toml).
zlib: Compiled from source via the libz-sys crate (statically linked).
Linking Summary
| Platform | iconv | zlib |
|---|---|---|
| Linux (glibc/musl) | Dynamic (system) | libz-sys (prefers system, falls back to source) |
| macOS (x86/ARM) | Dynamic (system) | libz-sys (uses system) |
| Windows (MSVC) | Static (vendored submodule) | libz-sys (compiled from source, static) |