[英]Bindgen failing because of relative paths in header file
我正在嘗試為 vmaf 構建一些綁定,但我遇到了一些問題。 vmaf 存儲庫中的 header 文件和 .c 文件位於不同的文件夾中。 我遇到一個問題,主vmaf.h文件引用同一目錄中的其他.h文件:#ifndef __VMAF_H__ #define __VMAF_H__ #include & ...
[英]Bindgen failing because of relative paths in header file
我正在嘗試為 vmaf 構建一些綁定,但我遇到了一些問題。 vmaf 存儲庫中的 header 文件和 .c 文件位於不同的文件夾中。 我遇到一個問題,主vmaf.h文件引用同一目錄中的其他.h文件:#ifndef __VMAF_H__ #define __VMAF_H__ #include & ...
[英]How to convert pointer to multidimensional slice/array
我正在寫一個 Rust function 的 c 綁定。Rust function 需要一個 3D 切片,其中 2 個維度的大小為 2。 本質上它是一段二維線段,其中一條線段由 2 個點表示。 這意味着段具有類型: 現在,因為我從 C 調用它,所以我在 FFI 邊界只有一個簡單的f32指針。 我來自 ...
[英]Coerce anyhow::Error to NjError for node-bindgen
我想用 node-bindgen 包裝 rust function 以在 Z686155AF75A60AD3E9E9E 中返回 promise。 有問題的 function 返回 anyhow anyhow:Error 。 這是我愚蠢的嘗試: 這導致: 你可以在這里找到當前的失火。 謝謝! 我試圖 ...
[英]How can I provide an alternate definition of an extern "C" FFI binding?
我正在使用第 3 方庫,其中包含與extern "C"函數的綁定: Item被定義為類型Pointer ,它被定義為*mut ::std::os::raw::c_char 。 這個特定的函數永遠不會改變Item指向的數據,所以我想為它提供一個不可變的值。 如果我可以控制第 3 方庫,我可以從 ...
[英]Pass 2D array of bytes to C in Rust
我用這個簽名在 C 中寫了一個 function: pages將是一個包含 128 個元素的數組,每個元素要么是 NULL,要么指向一個 8192 字節的 char 數組。 因此,一個 arrays 的數組具有固定的已知大小。 我需要在 Rust 中填充 arrays 並將它們傳遞給 C fun ...
[英]How to include Windows.h with rust bindgen?
我正在為 rust 中的 MSFS2020 啟動一個新插件,其中包含在 c++ 中編寫的 SimConnect SDK。我正在使用 bingen crates 創建與 SDK 的綁定。 我需要包含 Windows.h 才能使綁定正常工作,但出現以下錯誤: 如果我在 Visual Studio 上創 ...
[英]Rust program works on dev build but segfaults on release build
我在 Rust 中為相機庫編寫了一個包裝器,它命令和操作一個 16 位相機,並使用 bindgen 將圖像保存到文件中。 一旦我命令開始曝光(基本上是告訴相機拍攝圖像),我可以使用以下形式的函數抓取圖像: 在 C++ 中,這個函數是: 在 C++ 中,我可以傳入一個imgdata = new ...
[英]Vector contains data but reports length is 0, can be accessed by some functions
我在 Rust 中為相機庫編寫了一個包裝器,用於命令和操作相機,並使用 bindgen 將圖像保存到文件中。 一旦我命令開始曝光(基本上是告訴相機拍攝圖像),我可以使用以下形式的函數抓取圖像: 在 C++ 中,這個函數是: 在 C++ 中,我可以傳入一個格式為imgdata = new un ...
[英]How to send a pointer to another thread?
我為使用bindgen的相機創建了 C++ 庫的 Rust 包裝器,並在 C++ 庫中定義為typedef void camera_handle庫中的相機句柄 我能夠成功連接到相機並拍攝圖像,但是我想在一個單獨的線程上運行代碼來控制相機的溫度,本質上是根據我想要的相機的當前溫度來改變冷卻器的功率與 ...
[英]Rust: conversion between bindgen opaque type and String
我想在我的 Rust 代碼中調用 c++ 代碼,所以我使用 bindgen 來生成 FFI 代碼。 但是,我不知道如何在我的 Rust 代碼中將字符串轉換為 c++ 中的字符串。 C++ 演示代碼: #include <string> class Foo { private: ...
[英]Rust bindgen ignore include specific include from header file
我有一個頭文件可以說greetings.h: 我在 rust 中使用 bindgen 來生成從 c 頭文件到 rust 的文件。 但我想忽略生成include <hola.h>標頭並僅使用helllo.h和bye.h生成 greeting.h 。 我在 docs.rs bindgen ...
[英]can't set include path with bindgen
我正在嘗試使用 bindgen 生成與 Qt6 的綁定。 我已經按照這個答案嘗試了這個: - 但是當我嘗試編譯它時,我收到以下錯誤:- 我可以確認/usr/include/qt6/QtCore/QObject文件確實存在 ...
[英]Bindgen seems unable to find clang on OSX
雖然我確定這是我做錯了什么,但我似乎無法找到它。 我使用bindgen = "0.55.1" ,並試圖產生pjsip綁定,雖然這個問題似乎在這之前是很好。 這是構建的輸出: 我通過brew install llvm在macOS上的bindgen推薦安裝了 clang。 我已經驗證 /usr/lo ...
[英]Problems linking header files with Rust bindgen
根據https://rust-lang.github.io/rust-bindgen/tutorial-3.html上的 Rust bindgen 教程,我正在嘗試為現有的 C 頭文件生成 FFI。 但是,我在鏈接頭文件時遇到了問題。 https://github.com/studersi/ru ...
[英]Rust bindgen cannot find platform specific library?
我正在嘗試將我的簡單應用程序從 C 移植到 Rust。 它僅在我的 Mac 上運行,僅在 Mac 上有一個庫。 這是 C 代碼中失敗部分的簡化版本 // myLog.h #include <os/log.h> // macOS header void debug(const char ...
[英]Rust bindgen clang error, incompatible constant for this __builtin_neon function
嘗試為 Obj-C++ header 生成綁定,它是帶有 rust bindgen 的超級跨平台音頻庫的一部分。 我在 Catalina 10.15.6, 我被這個錯誤困住了。 搜索了很多,但似乎很少見。 我嘗試使用 Xcode 應用程序包中提供的 clang 進行嘗試,但無法成功。 該庫在 Xco ...
[英]Seeing bzlib.h not found when trying the Bindgen tutorial
我知道有一個類似的帖子,但我關注了它,我仍然看到這個問題,所以我想我會再問一次對不起。 我下載了 bbindgen-tutorial-bzip2-sys 並嘗試運行它,但出現以下錯誤 另一個用戶建議降級 .toml 中的 Bindgen 版本,我試過了,但我仍然看到問題,我還驗證了 bzip2 已安 ...
[英]Linking failed in rust bindgen
所以我有一個 header 庫(.h 文件的目錄),我需要在我的 rust 代碼中使用它。 為了讓這個工作,我一直在尋找各種板條箱來幫助我實現這個,看起來 bindgen 是最有希望的選擇。 我遵循了 bindgen 的文檔並創建了一個 wrapper.h 和一個 build.rs 文件。 在 bu ...
[英]How to get the size of a struct field in Rust without instantiating it
我有一個包含字節數組的結構。 這個結構實際上來自於bindgen產生的FFI綁定,它的大小是在C代碼中使用宏定義的,即: C 代碼:#define FOO_SIZE 100 struct the_struct { char foo[FOO_SIZE]; /* other fiel ...
[英]How do I convert a C-style enum generated by bindgen to another enum?
我正在為 C 庫和 Bindgen 生成的枚舉在 Rust 中創建綁定,例如: 我需要將這些轉換為: 從這個 C 庫導入常量值時: // C library const rmw_qos_history_policy_t some_value_from_C = RMW_QOS_POLICY_H ...