簡體   English   中英

由於 stdint.h,Bindgen 不會交叉編譯到 ARM

[英]Bindgen does not cross-compile to ARM due to stdint.h

我有一個 C 庫,我使用bindgen將其包裝到 Rust 板條箱中。 我的build.rs很簡單,與this非常相似。 C 庫在內部使用pthreads

原則上,我的交叉編譯適用於純 Rust 目標,但結合bindgen C 庫它停止工作。 為我的主機平台 ( x86_64 ) 進行編譯工作正常,但是當我嘗試為arm-unknown-linux-gnueabihf (Raspberry Pi Zero)* 進行交叉編譯時,我收到以下錯誤:

/home/andreas/rpi/rootfs/usr/include/stdint.h:43:9: error: unknown type name '__int_least8_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:44:9: error: unknown type name '__int_least16_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:45:9: error: unknown type name '__int_least32_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:46:9: error: unknown type name '__int_least64_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:49:9: error: unknown type name '__uint_least8_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:50:9: error: unknown type name '__uint_least16_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:51:9: error: unknown type name '__uint_least32_t'
/home/andreas/rpi/rootfs/usr/include/stdint.h:52:9: error: unknown type name '__uint_least64_t'
/home/andreas/rpi/rootfs/usr/include/stdio.h:39:10: fatal error: 'bits/types/__fpos_t.h' file not found
/home/andreas/rpi/rootfs/usr/include/stdint.h:43:9: error: unknown type name '__int_least8_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:44:9: error: unknown type name '__int_least16_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:45:9: error: unknown type name '__int_least32_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:46:9: error: unknown type name '__int_least64_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:49:9: error: unknown type name '__uint_least8_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:50:9: error: unknown type name '__uint_least16_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:51:9: error: unknown type name '__uint_least32_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdint.h:52:9: error: unknown type name '__uint_least64_t', err: true
/home/andreas/rpi/rootfs/usr/include/stdio.h:39:10: fatal error: 'bits/types/__fpos_t.h' file not found, err: true
thread 'main' panicked at 'Unable to generate bindings: ()', src/libcore/result.rs:1188:5

我將它與我系統上的 Rust 的內置工具和普通的clang + gcc工具鏈一起使用,並且可以很好地本地編譯。 現在我切換到raspi-toolchain並將CPATH設置為我從 Raspberry Pi Zero 下載的 header 文件,但問題仍然存在(它只是從基於pthread.h的錯誤變為stdint.h )。

build.rs中,我首先運行cmake然后執行以下操作:

let dst = cmake::Config::new("../")
        //...
        .build();
println!("cargo:rustc-link-search=native={}", dst.display());

我該如何從這里開始?

armv7 目標也是如此。

我不得不從 Raspi 部分添加更多標題:

/usr/include
/usr/include/arm-linux-gnueabihf
/usr/include/arm-linux-gnueabihf/sys

我也遇到過這個。 通過添加以下內容,我讓 bindgen 找到了正確的位置:

.clang_arg("--target=arm-unknown-linux-gnueabihf")

到綁定生成器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM