Questions tagged [bindgen]

Bindgen is a type-safe alternative to expression languages like UL and OGNL.

Bindgen uses code generation, but is implemented as a JDK6 annotation processor to provide (in Eclipse) a seamless editing/generation experience. The generated code is kept up to date as soon as “save” is hit.

15 questions
3
votes
0 answers

how can i stop memory leaks in rust FFI?

I'm trying to create some bindings from a C library for rust with bindgen and everything was going well until I realized that my program was having memory leak problems Thanks to heaptrack I was able to identify the function that was causing these…
3
votes
1 answer

Bindgen skipping definitions from C++ header file

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") …
Belval
  • 1,236
  • 10
  • 17
2
votes
1 answer

How can I export a function written in Rust to C code?

I'm venturing for the first time with Rust's FFI system and bindgen. So far it's going better than I expected but I have now hit a roadblock. My setup is the following: I have a library written in C that I can compile and that exposes some function…
pedro
  • 83
  • 5
2
votes
2 answers

Local crate not found when trying to update edition via cargo fix

Context: I have a local C library called 'libmaths' that then uses Bindgen to create a 'libmaths-sys' crate that is locally stored in the same directory as my project. Issue: I want to use some of the features in the 2021 edition of Rust and…
Jambalaya
  • 31
  • 4
2
votes
0 answers

How to avoid undefined behavior with rustified enums in bindgen?

bindgen has an option which enables the generation Rust enums (instead of constants) from C enums. However, the documentation states that it is capable of generating code that invokes undefined behavior under certain circumstances: Use this with…
QuaternionsRock
  • 832
  • 7
  • 14
1
vote
0 answers

How do I convert a static global variable generated by Bindgen into a global const?

Bindgen generates this from a static const C-style global structure: pub struct rmw_qos_profile_t { pub depth: usize, pub deadline: rmw_time_t, // ... } extern "C" { #[link_name = "\u{1}rmw_qos_profile_sensor_data"] pub static…
deb0ch
  • 1,133
  • 2
  • 16
  • 25
1
vote
0 answers

How to find Oracle's "oci.h" header when I use Bindgen on a Windows system?

I tried to use bindgen to automatically generate Rust FFI bindings to C and C++ libraries for the OCI bindings for an Oracle database. I followed the bindgen User Guide, and I did it like this: extern crate bindgen; use std::env; use…
yelan_fn
  • 41
  • 1
  • 3
0
votes
1 answer

Rust bindgen causes a "is not a valid Ident" error on build

Does anyone know how to start debugging this Rust bindgen indent issue? stderr thread 'main' panicked at '"vpx_codec_ctx_union_(unnamed_at_/usr/include/vpx/_/vpx_codec_h_206_3)" is not a valid Ident',…
Ignis Incendio
  • 190
  • 1
  • 10
0
votes
0 answers

Rust bindgen errors - E0412 and E0428

I'm trying to generate bindings for a largish C++ library while having no C++ experience. I've been hitting constant walls and I don't know how to proceed further, so I'm hoping someone could see the error stacktrace and might know what I'm doing…
Nathan
  • 1
0
votes
0 answers

How can I only generate #[derive(Clone)] by bindgen?

I am using bindgen to generate code with the following config. let mut builder = bindgen::Builder::default() .clang_arg("-std=c++11") .clang_arg("-x") .clang_arg("c++") .clang_arg("-Wno-pragma-once-outside-header") …
calvin
  • 2,125
  • 2
  • 21
  • 38
0
votes
1 answer

How do I create Rust bindings for the postgresql backend with rust bindgen?

I made a Cargo package which has the standard lib.rs, a Cargo.toml with bindgen = "0.59" under [build-dependencies], a wrapper.h with #include "rewrite/rewriteDefine.h" and a build.rs like so: extern crate bindgen; use std::env; use…
0
votes
1 answer

"unknown type name" when binding TPM Based Services' tbs.h using bindgen

I'm trying to bind tbs.h (TPM Based Services) via rust-bindgen. I have the following header: #ifndef TPM_WRAPPER_H #define TPM_WRAPPER_H #include #endif The build.rs file contains the path to the include directory of the Windows SDK: use…
nomad
  • 131
  • 1
  • 8
0
votes
1 answer

rust-bindgen bindings raise SIGSEGV

I generated bindings to Microsoft SEAL C++ Library using the rust-bindgen tool. My config: // Generate the bindings let bindings = bindgen::Builder::default() .generate_inline_functions(true) .derive_default(true) …
Belval
  • 1,236
  • 10
  • 17
0
votes
1 answer

Rust calling C, static const in C code

I have used rust-bindgen to generate rust interface code. Now in the C code you can find this: extern const struct mps_key_s _mps_key_ARGS_END; #define MPS_KEY_ARGS_END (&_mps_key_ARGS_END) Note that in the hole rest of the code _mps_key_ARGS_END…
nickik
  • 5,809
  • 2
  • 29
  • 35