Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bindgen skipping definitions from C++ header file

Tags:

rust

bindgen

I am trying to compile bindings for the SEAL C++ library. Here is my repo.

// Generate the bindings
let bindings = bindgen::Builder::default()
    .generate_inline_functions(true)
    .derive_default(true)
    .header("./seal/src/seal/seal.h")
    .clang_arg("-I./seal/src/")
    .clang_arg("-std=c++17")
    .clang_arg("-x")
    .clang_arg("c++")
    .opaque_type("std::.*")
    .whitelist_type("seal::.*")
    .generate()
    .expect("Unable to generate bindings");

let out_path = PathBuf::from("./src/");
bindings
    .write_to_file(out_path.join("bindings.rs"))
    .expect("Couldn't write bindings!");

bindings.rs does not have anything from defaultparams.h

What do I have to add to the Builder object to include defaultparams.h's functions in the generated bindings? I need coeff_modulus_128() for example.

I tried whitelisting the std::vector but it did not have any impact on the generated bindings.

like image 732
Belval Avatar asked Feb 04 '26 11:02

Belval


1 Answers

Solved by adding .whitelist_function("seal::.*") to the build.rs file. Since the inline functions weren't enclosed in a type, they were not whitelisted by the current config.

like image 119
Belval Avatar answered Feb 06 '26 14:02

Belval



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!