gpt4 book ai didi

c - 由于stdint.h,Bindgen不会交叉编译到ARM

转载 作者:行者123 更新时间:2023-12-03 11:39:54 58 4
gpt4 key购买 nike

我有一个C库,可以使用bindgen包装到Rust crate 中。我的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目标也会发生同样的情况。

最佳答案

我必须从Raspi部分添加更多标题:

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

关于c - 由于stdint.h,Bindgen不会交叉编译到ARM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60410934/

58 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com