【发布时间】:2020-06-10 03:36:11
【问题描述】:
我有一个 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 下载的头文件,但问题仍然存在(它只是从基于pthread.h 的错误变为stdint.h)。
在build.rs 中,我首先运行cmake,然后执行以下操作:
let dst = cmake::Config::new("../")
//...
.build();
println!("cargo:rustc-link-search=native={}", dst.display());
我该如何从这里开始?
armv7 目标也是如此。
【问题讨论】:
标签: c rust cross-compiling rust-cargo