How To: Build Tectonic: Install Dependencies With cargo-vcpkg

A convenient, fairly cross-platform way to install Tectonic’s dependencies is using the cargo-vcpkg tool. It will take care of setting up vcpkg, providing the needed dependencies, and informing Tectonic’s build system about how to find them. It will, however, generally require that the dependencies be compiled from scratch.

First, install cargo-vcpkg if needed:

cargo install cargo-vcpkg

Then, in the Tectonic source tree, run the command to obtain all of the needed dependencies:

cargo vcpkg build

Then set the VCPKG_ROOT environment variable to tell the build system where the dependencies may be found. In a bash shell, a good command is:

export VCPKG_ROOT="${CARGO_TARGET_DIR:-$(pwd)/target}/vcpkg"

If you’re building on Windows, you’ll likely want to make sure that your RUSTFLAGS variable includes a +crt-static target feature to get the vcpkg build scripts to use the x64-windows-static vcpkg triplet, which is the default one used by our cargo-vcpkg setup, as opposed to x64-windows-static-md, which is activated otherwise. And if you’ve done the full vcpkg install, you might as well build with an external Harfbuzz. Therefore a full Windows build invocation — launched from bash — might look like this:

cargo vcpkg build
export VCPKG_ROOT="${CARGO_TARGET_DIR:-$(pwd)/target}/vcpkg"
export RUSTFLAGS='-Ctarget-feature=+crt-static'  # Windows only
export TECTONIC_DEP_BACKEND=vcpkg
cargo build --features external-harfbuzz

Note that if you are going to run additional commands such as cargo test, you’re going to need to ensure that the same environment variables and feature flags are used consistently.