Fail to build when cross-compiling for Windows
Probably the same cause as #6
Build command:
cargo build --target i686-pc-windows-gnu
Error:
error: failed to run custom build command for `libusb-sys v0.2.3`
process didn't exit successfully: `target/debug/build/libusb-sys-6bbfe3932132cdbf/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Hello, first you may edit the file
vim ~/.cargo/config
then add following such as
[target.x86_64-pc-windows-gnu]
linker="/Path/Cross/Compiler/x86_64-pc-windows-gnu/bin/x86_64-w64-mingw32-gcc"
ar="/Path/Cross/Compiler/x86_64-pc-windows-gnu/bin/x86_64-w64-mingw32-gcc-ar"
then download the libusb source from libusb website
in the source folder you may run
./configure CC=/Path/Cross/Compiler/x86_64-pc-windows-gnu/bin/x86_64-w64-mingw32-gcc --prefix=/PrefixPath/lib-cross/x86_64-pc-windows-gnu --host=x86_64-w64-mingw32 --disable-udev
and run
make install
if you want to make the host for windows you will edit the --host=x86_64-w64-mingw32 or --host=i686-w64-mingw32
then in the folder /PrefixPath/lib-cross/x86_64-pc-windows-gnu will appear the files.
Set the environment
PKG_CONFIG_LIBDIR=/PrefixPath/lib-cross/x86_64-pc-windows-gnu/lib/pkgconfig
PKG_CONFIG_ALLOW_CROSS=1
Good luck!