autobind
Version, currently 0.5.110 versions
github.com/j8r/crystal-autobind
Automatic C binding generator for Crystal
Installation
# Add this to your shard.yml
dependencies:
autobind:
github: j8r/crystal-autobind
version: ~> 0.5.1Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- Apache-2.0
- Authors
- Julien Portalier, Julien Reichardt
- Target
autobindfrom src/autobind.cr
- Executable
autobind
Dependencies
Runtime Dependencies
- clang*github: ysbaddaden/clang.cr, commit: 349a9185bc9a1756dd4c682c000764ec31a3b5da
README
Autobind
Automatic C bindings generator for Crystal
Built from the awesome clang.cr done by ysbaddaden
How to use (recommended)
Installation
Add this block to your application's shard.yml:
dependencies:
autobind:
github: j8r/crystal-autobind
scripts:
postinstall: ./gen-bindings.sh
You can create a gen-bindings.sh script, with the permissions chmod 750
#!/bin/sh
# Example of generating the bindings for `errno` at `src/libc/errno.cr`
mkdir -p src/libc && lib/autobind/bin/autobind -I/usr/include errno.h > src/libc/errno.cr
The postinstall script will only be runned when included as a dependency on a project.
Usage
The newly generated .cr bindings can be used to create a documented shard wrapper, that can be then require and used as a shard in your application.
The development headers of the library are required whether the bindings are previously generated or not.
The only caveat is to have clang/libclang installed to regenerate the bindings.
The bindings directory can thus be ignored in .gitignore to avoid versioning:
/bin
/lib
/shard.lock
/src/libc
Build
Ensure to have libclang installed
Install dependencies:
shards install
Build autobind:
crystal build src/autobind.cr
Usage examples
You will need the development headers of your targeted library, usually coming inside the dev packages of you distribution.
./autobind -I/usr/include errno.h > errno.cr
./autobind -I/usr/lib/llvm-6.0/include llvm-c/Core.h --remove-enum-prefix=LLVM --remove-enum-suffix > Core.cr
./autobind -I/usr/lib/llvm-6.0/include clang-c/Index.h --remove-enum-prefix > Index.cr
Reference
License
Distributed under the Apache 2.0 license.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.5.1- Tagged
- Nov 17, 2018
- Commit
ea05566e0a6d- Indexed
- yes
Dependents
Repository
github.com/j8r/crystal-autobind
Metadata
- Created
- Aug 13, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 10