binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Rust Api Bug

Open yujack008 opened this issue 1 year ago • 2 comments

I getting start with https://rust.binary.ninja/binaryninja/index.html#writing-a-plugin My rustc version is rustc 1.77.0 (aedd173a2 2024-03-17) My LIBCLANG_PATH is "E:\clang+llvm-18.1.5-x86_64-pc-windows-msvc\bin" step: 1.cargo new --lib deobf 2.edit Cargo.toml

[lib]
crate-type = ["cdylib"]

[dependencies]
binaryninja = {git = "https://github.com/Vector35/binaryninja-api.git", branch = "dev"}

3.cargo build

then get so much error!

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeQualifiedNameTypeAndId` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2489:13
     |
2470 | pub struct QualifiedNameTypeAndId(pub(crate) BNQualifiedNameTypeAndId);
     | ----------------------------------------------------------------------- similarly named tuple struct `QualifiedNameTypeAndId` defined here
...
2489 |             BNFreeQualifiedNameTypeAndId(&mut self.0);
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple struct with a similar name exists: `QualifiedNameTypeAndId`

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeTypeIdList` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2500:9
     |
2500 |         BNFreeTypeIdList(raw, count);
     |         ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNAllocString` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2527:23
     |
2527 |                 name: BNAllocString(name.into_bytes_with_nul().as_ref().as_ptr() as *mut _),
     |                       ^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeString` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2567:13
     |
     |             ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeNameAndTypeList` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2580:9
     |
2580 |         BNFreeNameAndTypeList(raw, count);
     |         ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeType` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2649:18
     |
2649 |         unsafe { BNFreeType(handle.0.type_) }
     |                  ^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNFreeDataVariables` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2659:9
     |
2659 |         BNFreeDataVariables(raw, count);
     |         ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `BNGetArchitectureIntrinsicName` in this scope
    --> D:\Projects\Rust\binaryninja-api\rust\src\types.rs:2722:33
     |
2722 |         let name_ptr = unsafe { BNGetArchitectureIntrinsicName(self.arch.0, self.index) };
     |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

yujack008 avatar May 10 '24 08:05 yujack008

Are you using the build.rs from the guide?

negasora avatar May 10 '24 12:05 negasora

Are you using the build.rs from the guide?

i have build fine on llvm 17.0.6

yujack008 avatar May 11 '24 09:05 yujack008

I believe that this is a duplicate from Slack. User resolved this by downgrading to LLVM 17.0.6. Internally we're still on LLVM 16. No real idea about the effort required to fix this will be, but I'm hoping it's just some new flags we need to set (or something similar). I'll leave this open to track the status of bindgen/LLVM18 support.

ElykDeer avatar May 23 '24 17:05 ElykDeer

This should have been fixed when I pulled in #5700 and I didn't realize there was a separate issue created for it. If anyone is still having issues, please let me know, but 4.1 stable and onward should work with LLVM 18 now that the bindgen version has been bumped.

fuzyll avatar Aug 19 '24 16:08 fuzyll