Reputation: 526
I have a C library that I wrap into a Rust crate using bindgen
. My build.rs
is straightforward and very similar to this. The C library is using pthreads
internally.
In principle, my cross-compilation works for pure Rust targets, but in combination with the bindgen
C-library it stops working. Compiling for my host platform (x86_64
) works fine, but when I try to cross-compile for arm-unknown-linux-gnueabihf
(Raspberry Pi Zero)*, I get the following errors:
/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
I used it with the built-in tools of Rust and with the normal clang
+ gcc
toolchain on my system and compiles fine natively. Now I switched to raspi-toolchain and set the CPATH
to the header files I have downloaded from my Raspberry Pi Zero, but the problem persists (it only changes from errors based on pthread.h
to stdint.h
).
In build.rs
, I first run cmake
and then I do the following:
let dst = cmake::Config::new("../")
//...
.build();
println!("cargo:rustc-link-search=native={}", dst.display());
How can I proceed from here?
The same happens for the armv7 target.
Upvotes: 2
Views: 1719
Reputation: 262
I encountered this too. I got bindgen to look in the right spot by adding:
.clang_arg("--target=arm-unknown-linux-gnueabihf")
to the bindgen builder.
Upvotes: 1
Reputation: 526
I had to add more headers from the Raspi part:
/usr/include
/usr/include/arm-linux-gnueabihf
/usr/include/arm-linux-gnueabihf/sys
Upvotes: 0