Bindgen basic help


#1

Hi,
I’m trying to use bindgen to create bindings to C++ code (kea dhcp server).
I’m following guides but I’ve stumbled on first step… :slight_smile:
My Cargo.toml contains required declarations:

[package]
build = "build.rs"

[dependencies]
bindgen = "0.26.1"

build.rs in my crate root folder have content according to example from bindgen:

extern crate bindgen;

use std::env;
use std::path::PathBuf;

fn main() {
// code here

And I’m getting error when running cargo build:

error[E0463]: can't find crate for `bindgen`
 --> build.rs:1:1
  |
1 | extern crate bindgen;
  | ^^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

What I’m doing wrong ?


#2

Put it in [build-dependencies] like https://github.com/compass-rs/sass-rs/pull/11/files#diff-3f5590e43a4a71147163b6b694dc7c66R16


#3

Ha,

This helped. Thanks !

Why such information is not present in any bindgen doc/example ?


#4

I just had a skim through their guide and found this.