Thread 'main' panicked at 'libclang error; possible causes include:
⚓ Rust 📅 2025-08-08 👤 surdeus 👁️ 11Hello,
I am trying to generate the C structs for Rust using the bindgen. Below is my build.rs file content
use std::env;
use std::path::PathBuf;
fn main()
{
let illd_include = r"<path>\Infineon_Libraries\iLLD\TC37A";
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.use_core()
.ctypes_prefix("core::ffi")
.allowlist_type("IfxDma_Dma_Channel")
.allowlist_type("IfxDma_Dma_ChannelConfig")
.clang_arg(format!("-I{}", illd_include))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}
Wrapper.h
#include "IfxDma_Dma.h"
I am encountering the following error:
error: failed to run custom build command for
rust_code v0.1.0 (<path>\source_code\DMA_Data_Transfer\rust_code)
Caused by:
process didn't exit successfully: <path>\source_code\DMA_Data_Transfer\rust_code\target\debug\build\rust_code-4407a73162f37964\build-script-build (exit code: 101)
--- stderr
thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!', .cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.68.1\ir\context.rs:553:15
note: run withRUST_BACKTRACE=1environment variable to display a backtrace
ninja: build stopped: subcommand failed.
[ERROR] Build failed
I am unable to fix the issue. It would be of great help to know the issue and fix it.
Thanks
1 post - 1 participant
🏷️ Rust_feed