yelan_fn
yelan_fn

Reputation: 51

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 std::path::PathBuf;

fn main() {
    println!("cargo:rustc-link-search={}", "E:\\Rust\\instantclient_11_2\\sdk\\lib\\msvc");
    let bindings = bindgen::Builder::default()
        .header("wrapper.h")
        .clang_arg("-I/E:\\Rust\\instantclient_11_2\\sdk\\include")
        .generate()
        .expect("Unable to generate to bindings");

    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings.write_to_file(out_path.join("oci.rs"))
        .expect("Couldn't write bindings");
}

My Oracle client SDK path is E:/Rust/instantclient_11_2, and the active toolchain is nightly-x86_64-pc-windows-msvc The wrapper.h file is:

#include <oci.h>

When I run cargo build, I get the following error:

Compiling test_bindgen v0.1.0 (file:///E:/Rust/test_bindgen)
error: failed to run custom build command for `test_bindgen v0.1.0 (file:///E:/Rust/test_bindgen)`
process didn't exit successfully: `E:\Rust\test_bindgen\target\debug\build\test_bindgen-67bec61306f8f8d4\build-script-build` (ex
it code: 101)
--- stdout
cargo:rustc-link-search=E:\Rust\instantclient_11_2\sdk\lib\msvc
wrapper.h:1:10: fatal error: 'oci.h' file not found, err: true

--- stderr
wrapper.h:1:10: fatal error: 'oci.h' file not found
thread 'main' panicked at 'Unable to generate to bindings: ()', src\libcore\result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

If I perform the same operation on Ubuntu 16.04 it succeeds, but I don't know how to do it on a Windows system.

Upvotes: 1

Views: 547

Answers (0)

Related Questions