All Projects → rust-lang → Rust Bindgen

rust-lang / Rust Bindgen

Licence: bsd-3-clause
Automatically generates Rust FFI bindings to C (and some C++) libraries.

Programming Languages

C++
36643 projects - #6 most used programming language
rust
11053 projects
c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Rust Bindgen

Python Mpv
Python interface to the awesome mpv media player
Stars: ✭ 245 (-90.01%)
Mutual labels:  bindings, ffi
rust-lang-interop
Rust language interoperability with other languages - C, C++ etc.
Stars: ✭ 53 (-97.84%)
Mutual labels:  ffi, bindings
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (-77.54%)
Mutual labels:  bindings, codegen
renderdoc-rs
RenderDoc application bindings for Rust
Stars: ✭ 28 (-98.86%)
Mutual labels:  ffi, bindings
rsmpeg
A Rust crate that exposes FFmpeg's power as much as possible.
Stars: ✭ 390 (-84.1%)
Mutual labels:  ffi, bindings
Fruity
Rusty bindings for Apple libraries
Stars: ✭ 72 (-97.06%)
Mutual labels:  bindings, ffi
Sequelize Ui
Browser-based GUI for previewing and generating Sequelize project files.
Stars: ✭ 142 (-94.21%)
Mutual labels:  codegen
Xstate Codegen
A codegen tool for 100% TS type-safety in XState
Stars: ✭ 158 (-93.56%)
Mutual labels:  codegen
React Native Lazy Index
RAM bundle friendly, bundle-time generated `index.js`
Stars: ✭ 143 (-94.17%)
Mutual labels:  codegen
Gintro
High level GObject-Introspection based GTK3/GTK4 bindings for Nim language
Stars: ✭ 141 (-94.25%)
Mutual labels:  bindings
Cppsharp
Tools and libraries to glue C/C++ APIs to high-level languages
Stars: ✭ 2,221 (-9.46%)
Mutual labels:  bindings
Net Vips
.NET binding for libvips
Stars: ✭ 173 (-92.95%)
Mutual labels:  bindings
Zydis
Fast and lightweight x86/x86-64 disassembler and code generation library
Stars: ✭ 2,168 (-11.62%)
Mutual labels:  codegen
Gatsby Plugin Typegen
High-performance TypeScript/Flow code generation for GatsbyJS queries.
Stars: ✭ 144 (-94.13%)
Mutual labels:  codegen
Rustr
Rust and R Integration
Stars: ✭ 160 (-93.48%)
Mutual labels:  ffi
Swagger Axios Codegen
swagger client to use axios and typescript
Stars: ✭ 143 (-94.17%)
Mutual labels:  codegen
Goluwa
a game framework written in luajit
Stars: ✭ 173 (-92.95%)
Mutual labels:  ffi
Gopherjs Vue
VueJS bindings for gopherjs
Stars: ✭ 142 (-94.21%)
Mutual labels:  bindings
Xcassetpacker
A command line tool for converting a folder of images into an .xcasset package for Xcode
Stars: ✭ 150 (-93.89%)
Mutual labels:  codegen
Piecash
Pythonic interface to GnuCash SQL documents
Stars: ✭ 172 (-92.99%)
Mutual labels:  bindings

crates.io docs.rs

bindgen

bindgen automatically generates Rust FFI bindings to C (and some C++) libraries.

For example, given the C header doggo.h:

typedef struct Doggo {
    int many;
    char wow;
} Doggo;

void eleven_out_of_ten_majestic_af(Doggo* pupper);

bindgen produces Rust FFI code allowing you to call into the doggo library's functions and use its types:

/* automatically generated by rust-bindgen 0.99.9 */

#[repr(C)]
pub struct Doggo {
    pub many: ::std::os::raw::c_int,
    pub wow: ::std::os::raw::c_char,
}

extern "C" {
    pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
}

Users Guide

📚 Read the bindgen users guide here! 📚

MSRV

The minimum supported Rust version is 1.46.

No MSRV bump policy has been established yet, so MSRV may increase in any release.

API Reference

API reference documentation is on docs.rs

Environment Variables

In addition to the library API and executable command-line API, bindgen can be controlled through environment variables.

End-users should set these environment variables to modify bindgen's behavior without modifying the source code of direct consumers of bindgen.

  • BINDGEN_EXTRA_CLANG_ARGS: extra arguments to pass to clang
    • Arguments are whitespace-separated
    • Use shell-style quoting to pass through whitespace
    • Examples:
      • Specify alternate sysroot: --sysroot=/path/to/sysroot
      • Add include search path with spaces: -I"/path/with spaces"
  • BINDGEN_EXTRA_CLANG_ARGS_<TARGET>: similar to BINDGEN_EXTRA_CLANG_ARGS, but used to set per-target arguments to pass to clang. Useful to set system include directories in a target-specific way in cross-compilation environments with multiple targets. Has precedence over BINDGEN_EXTRA_CLANG_ARGS.

Additionally, bindgen uses libclang to parse C and C++ header files. To modify how bindgen searches for libclang, see the clang-sys documentation. For more details on how bindgen uses libclang, see the bindgen users guide.

Releases

We don't follow a specific release calendar, but if you need a release please file an issue requesting that (ping @emilio for increased effectiveness).

Contributing

See CONTRIBUTING.md for hacking on bindgen!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].