run-llama/liteparse · critical
Unable to generate bindings
Error message
Unable to generate bindings
What it means
The pdfium-sys build script panics because bindgen failed to generate Rust FFI bindings from the PDFium C headers (the `bindgen::Builder::generate()` call returned an Err). This happens when libclang cannot parse `wrapper.h` or the PDFium headers found under the include directory. It is a build-time panic, so the crate fails to compile with this message as the panic output.
Solutions
- Install libclang (e.g. `apt install libclang-dev` / `brew install llvm` and set LIBCLANG_PATH) and rebuild.
- Verify the include directory contains the PDFium public headers (fpdfview.h etc.) and is correctly passed to the build script; fix the path/env var that supplies it.
- Build with the `bindgen` feature disabled so the pre-generated `bindings.rs` shipped in the crate is used instead of running bindgen.
- Pin/check the PDFium version whose headers are being parsed; regenerate or update bindgen if the headers use unsupported constructs.
Example fix
// before: failing build with missing libclang # apt install clang libclang-dev # export LIBCLANG_PATH=/usr/lib/llvm-14/lib // or, in Cargo.toml, skip bindgen entirely and use the pre-generated bindings // before cargo build -p pdfium-sys --features bindgen // after cargo build -p pdfium-sys
Defensive patterns
Strategy: validation
Validate before calling
# shell — before building cargo build -p pdfium-sys --features bindgen 2>&1 | grep -q 'Unable to generate bindings' && \ echo 'check libclang + PDFium headers' # or programmatically ensure prerequisites: which clang; echo $LIBCLANG_PATH; ls $PDFIUM_INCLUDE/fpdfview.h
Prevention
- Install libclang as a pinned CI dependency (e.g. apt install libclang-dev) before cargo build
- Prefer the default (non-bindgen) build that uses the pre-generated bindings.rs
- Assert the PDFium include dir exists and contains fpdfview.h in build scripts/CI setup
- Pin bindgen and PDFium header versions known to work together
When it happens
Trigger: Building pdfium-sys with the `bindgen` feature enabled and either (a) the PDFium C headers are missing/incomplete in the include dir passed via `-I`, (b) libclang is absent or an incompatible version, or (c) the header contents are malformed/incompatible so the clang parse fails and `generate()` returns Err.
Common situations: Fresh CI/dev machines without libclang installed (e.g. no `libclang-dev` / LLVM installed); a PDFium checkout where the `public/` include dir is wrong or empty; PDFium version changes introducing headers bindgen cannot parse; cross-compiling where the wrong libclang/headers are picked up.
Related errors
- Couldn't write bindings!
- pdfium not loaded — call…
- failed to load pdfium shared library
- no data on stdin (input `-` expects a document piped in…
- no data on stdin (input `-` expects a document piped in…
AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08).
Data as JSON: /api/errors/475d6e5fec24bcb2.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pdfium-sys/build.rs:286
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg(format!("-I{}", include_dir.display()))
.allowlist_function("FPDF.*")
.allowlist_function("FORM_.*")
.allowlist_function("FPDFText_.*")
.allowlist_function("FPDFPage.*")
.allowlist_function("FPDFLink_.*")
.allowlist_function("FPDFFont_.*")
.allowlist_type("FPDF.*")
.allowlist_type("FS_.*")
.allowlist_var("FPDF.*")
.allowlist_var("FLAT.*")
.derive_debug(true)
.derive_default(true)
.layout_tests(false)
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("Unable to generate bindings");
bindings
.write_to_file(&out_file)
.expect("Couldn't write bindings!");
}
#[cfg(not(feature = "bindgen"))]
{
let _ = include_dir;
let pregenerated = Path::new(env!("CARGO_MANIFEST_DIR")).join("bindings.rs");
fs::copy(&pregenerated, &out_file).unwrap_or_else(|e| {
panic!(
"Failed to copy pre-generated bindings from {}: {e}",
pregenerated.display()
)
});
}
}View on GitHub (pinned to 22d2dd8cd7)