a1ien / rusb

A safe Rust wrapper for libusb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to crosscompile with i686-pc-windows-gnu toolchain

makavity opened this issue · comments

Hello!
IDK, should I type this issue to https://github.com/cross-rs/cross or here, so just put it here firstly :)
When I try to compile rusb just as crate with cross - all is fine.
image

Next steps:

  1. Create blank project with rusb as dependency:
[package]
name = "test-libusb"
version = "0.1.0"
edition = "2021"

[dependencies]
rusb = { version = "0.9", features = ["vendored"] }
  1. Cross.toml
[target.i686-pc-windows-gnu]
pre-build = [
  "dpkg --add-architecture $CROSS_DEB_ARCH",
  "apt-get update && apt-get install --assume-yes libusb-1.0-0-dev:$CROSS_DEB_ARCH"
]
  1. Run cross build --release --target i686-pc-windows-gnu

Error:

~/.../mak/test-libusb >>> cargo clean                                                                               ±[●][master]
~/.../mak/test-libusb >>> cross build --release --target i686-pc-windows-gnu                                        ±[●][master]
[+] Building 0.1s (5/6)                                                                                           docker:default
[+] Building 0.2s (6/6) FINISHED                                                                                  docker:default
 => [internal] load build definition from Dockerfile.i686-pc-windows-gnu-custom                                             0.0s
 => => transferring dockerfile: 236B                                                                                        0.0s
 => [internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 2B                                                                                             0.0s
 => [internal] load metadata for ghcr.io/cross-rs/i686-pc-windows-gnu:local                                                 0.0s
 => [1/2] FROM ghcr.io/cross-rs/i686-pc-windows-gnu:local                                                                   0.0s
 => CACHED [2/2] RUN eval "dpkg --add-architecture $CROSS_DEB_ARCH
apt-get update && apt-get install --assume-yes libusb-1  0.0s                                                               0.0s
 => exporting to image                                                                                                      0.0s
 => => exporting layers                                                                                                     0.0s
 => => writing image sha256:1b1746eae1c3c09db0692740ec01cb0116d5f3a58451728845dd8f777b1e38b7                                0.0s
 => => naming to docker.io/library/cross-custom-test-libusb:i686-pc-windows-gnu-e4d80-pre-build                             0.0s
   Compiling pkg-config v0.3.27
   Compiling cc v1.0.79
   Compiling libc v0.2.147
   Compiling rusb v0.9.2
   Compiling libusb1-sys v0.6.4
   Compiling test-libusb v0.1.0 (/project)
error: linking with `i686-w64-mingw32-gcc-posix` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/rust/bin" VSLANG="1033" "i686-w64-mingw32-gcc-posix" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-Wl,--large-address-aware" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o" "/tmp/rustcNekuXb/symbols.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.test_libusb.93e72a83-cgu.0.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.test_libusb.93e72a83-cgu.1.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.test_libusb.93e72a83-cgu.2.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.test_libusb.93e72a83-cgu.3.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.test_libusb.93e72a83-cgu.4.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.3bxcnx9mkf3ghzbl.rcgu.o" "-L" "/target/i686-pc-windows-gnu/release/deps" "-L" "/target/release/deps" "-L" "/target/i686-pc-windows-gnu/release/build/libusb1-sys-dcb5c5945316bd95/out" "-L" "/rust/lib/rustlib/i686-pc-windows-gnu/lib" "-Wl,-Bstatic" "/target/i686-pc-windows-gnu/release/deps/librusb-a058ee873e71f021.rlib" "/target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-b3cdab48e3747580.rlib" "/target/i686-pc-windows-gnu/release/deps/liblibc-e5d0f25440c78d78.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libstd-c8d5429958fa48cb.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-4921316c6ea19630.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libobject-fb3a3dc967602ac1.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libmemchr-ca7141bfd4fcd5fd.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libaddr2line-91a5ac3c0a49fa70.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libgimli-17b6609e4b56f5b8.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_demangle-1bd29505cf4a5212.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libstd_detect-b839d9966605343b.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libhashbrown-e407f0eefbfd2223.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libminiz_oxide-d8a4c1004cc67e46.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libadler-d39b2beaa1d6e59a.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_alloc-300df6f910da93ad.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libunwind-f130ab8c783471a6.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcfg_if-546025daf57cf85a.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/liblibc-6b9e0f1183ff4812.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/liballoc-093bc6f211360e70.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_core-ea8896ccb4d17902.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcore-25b883f5a4a24178.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcompiler_builtins-ea3cf4868e56be51.rlib" "-Wl,-Bdynamic" "-luser32" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "/rust/lib/rustlib/i686-pc-windows-gnu/lib" "-o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-cc4afcadb9115700.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,-O1" "-nodefaultlibs" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/rsend.o"
  = note: /usr/bin/i686-w64-mingw32-ld: warning: resolving _WakeAllConditionVariable by linking to _WakeAllConditionVariable@4
          Use --enable-stdcall-fixup to disable these warnings
          Use --disable-stdcall-fixup to disable these fixups
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-b3cdab48e3747580.rlib(io.o):io.c:(.text$libusb_wait_for_event+0xcc): undefined reference to `SleepConditionVariableCS'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-b3cdab48e3747580.rlib(io.o):io.c:(.text$usbi_io_init+0x57): undefined reference to `InitializeConditionVariable'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-b3cdab48e3747580.rlib(windows_common.o):windows_common.c:(.text$windows_cancel_transfer+0x21): undefined reference to `CancelIoEx'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-b3cdab48e3747580.rlib(threads_windows.o):threads_windows.c:(.text$usbi_cond_timedwait+0x48): undefined reference to `SleepConditionVariableCS'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `test-libusb` due to previous error

And if I remove vendored feature from rusb, i'm getting this:

~/.../mak/test-libusb >>> nano Cargo.toml                                                                           ±[●][master]
~/.../mak/test-libusb >>> cross build --release --target i686-pc-windows-gnu                                        ±[●][master]
[+] Building 0.1s (6/6) FINISHED                                                                                  docker:default
 => [internal] load build definition from Dockerfile.i686-pc-windows-gnu-custom                                             0.0s
 => => transferring dockerfile: 236B                                                                                        0.0s
 => [internal] load .dockerignore                                                                                           0.0s
 => => transferring context: 2B                                                                                             0.0s
 => [internal] load metadata for ghcr.io/cross-rs/i686-pc-windows-gnu:local                                                 0.0s
 => [1/2] FROM ghcr.io/cross-rs/i686-pc-windows-gnu:local                                                                   0.0s
 => CACHED [2/2] RUN eval "dpkg --add-architecture $CROSS_DEB_ARCH
apt-get update && apt-get install --assume-yes libusb-1  0.0s
 => exporting to image                                                                                                      0.0s
 => => exporting layers                                                                                                     0.0s
 => => writing image sha256:1b1746eae1c3c09db0692740ec01cb0116d5f3a58451728845dd8f777b1e38b7                                0.0s
 => => naming to docker.io/library/cross-custom-test-libusb:i686-pc-windows-gnu-e4d80-pre-build                             0.0s
   Compiling libusb1-sys v0.6.4
   Compiling rusb v0.9.2
   Compiling test-libusb v0.1.0 (/project)
error: linking with `i686-w64-mingw32-gcc-posix` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/rust/bin" VSLANG="1033" "i686-w64-mingw32-gcc-posix" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-Wl,--large-address-aware" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o" "/tmp/rustcZv1XGS/symbols.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.0.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.2.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.3.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.3g1886zswzu7s1kw.rcgu.o" "-L" "/target/i686-pc-windows-gnu/release/deps" "-L" "/target/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/rust/lib/rustlib/i686-pc-windows-gnu/lib" "-Wl,-Bstatic" "/target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib" "/target/i686-pc-windows-gnu/release/deps/liblibusb1_sys-26a51fc47c3fce55.rlib" "/target/i686-pc-windows-gnu/release/deps/liblibc-e5d0f25440c78d78.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libstd-c8d5429958fa48cb.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libpanic_unwind-4921316c6ea19630.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libobject-fb3a3dc967602ac1.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libmemchr-ca7141bfd4fcd5fd.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libaddr2line-91a5ac3c0a49fa70.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libgimli-17b6609e4b56f5b8.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_demangle-1bd29505cf4a5212.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libstd_detect-b839d9966605343b.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libhashbrown-e407f0eefbfd2223.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libminiz_oxide-d8a4c1004cc67e46.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libadler-d39b2beaa1d6e59a.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_alloc-300df6f910da93ad.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libunwind-f130ab8c783471a6.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcfg_if-546025daf57cf85a.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/liblibc-6b9e0f1183ff4812.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/liballoc-093bc6f211360e70.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/librustc_std_workspace_core-ea8896ccb4d17902.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcore-25b883f5a4a24178.rlib" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/libcompiler_builtins-ea3cf4868e56be51.rlib" "-Wl,-Bdynamic" "-lusb-1.0" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "/rust/lib/rustlib/i686-pc-windows-gnu/lib" "-o" "/target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,-O1" "-nodefaultlibs" "/rust/lib/rustlib/i686-pc-windows-gnu/lib/rsend.o"
  = note: /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o:test_libusb.e3318f:(.text+0x9): undefined reference to `libusb_get_bus_number@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o:test_libusb.e3318f:(.text+0x19): undefined reference to `libusb_ref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o:test_libusb.e3318f:(.text+0x44): undefined reference to `libusb_get_device_descriptor@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o:test_libusb.e3318f:(.text+0xb9): undefined reference to `libusb_get_device_address@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.1.rcgu.o:test_libusb.e3318f:(.text+0xc9): undefined reference to `libusb_unref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.3.rcgu.o:test_libusb.e3318f:(.text+0x2b): undefined reference to `libusb_free_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.3.rcgu.o:test_libusb.e3318f:(.text+0x5c): undefined reference to `libusb_ref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x15): undefined reference to `libusb_unref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x27): undefined reference to `libusb_free_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x70): undefined reference to `libusb_ref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x7a): undefined reference to `libusb_get_device_descriptor@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0xd0): undefined reference to `libusb_get_bus_number@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0xd9): undefined reference to `libusb_get_device_address@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x16c): undefined reference to `libusb_unref_device@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/test_libusb-aa964f0bb2c572d1.test_libusb.e3318f82-cgu.4.rcgu.o:test_libusb.e3318f:(.text+0x17b): undefined reference to `libusb_free_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x13): undefined reference to `libusb_has_capability@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x63): undefined reference to `libusb_has_capability@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0xb6): undefined reference to `libusb_has_capability@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x106): undefined reference to `libusb_has_capability@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x15f): undefined reference to `libusb_get_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x1e0): undefined reference to `libusb_set_debug@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.13.rcgu.o):rusb.77f876ab-cgu.:(.text+0x24d): undefined reference to `libusb_open_device_with_vid_pid@12'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x18): undefined reference to `libusb_init@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0xb8): undefined reference to `libusb_init@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x175): undefined reference to `libusb_exit@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x189): undefined reference to `libusb_exit@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x1af): undefined reference to `libusb_get_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x284): undefined reference to `libusb_init@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.4.rcgu.o):rusb.77f876ab-cgu.:(.text+0x3b6): undefined reference to `libusb_set_option'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.11.rcgu.o):rusb.77f876ab-cgu.:(.text+0x6d): undefined reference to `libusb_exit@4'
          /usr/bin/i686-w64-mingw32-ld: /target/i686-pc-windows-gnu/release/deps/librusb-05413b9a10098af0.rlib(rusb-05413b9a10098af0.rusb.77f876ab-cgu.15.rcgu.o):rusb.77f876ab-cgu.:(.text+0x26f): undefined reference to `libusb_get_device_list@8'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2.o):(.text+0x1b5f): undefined reference to `pthread_once'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1a3): undefined reference to `pthread_mutex_init'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfc0): undefined reference to `pthread_once'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfcc): undefined reference to `pthread_mutex_lock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10ca): undefined reference to `pthread_once'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10d6): undefined reference to `pthread_mutex_lock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1193): undefined reference to `pthread_once'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x119f): undefined reference to `pthread_mutex_lock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x11d5): undefined reference to `pthread_mutex_unlock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x124f): undefined reference to `pthread_mutex_unlock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12bf): undefined reference to `pthread_once'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x12cb): undefined reference to `pthread_mutex_lock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x1306): undefined reference to `pthread_mutex_unlock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x13d9): undefined reference to `pthread_mutex_unlock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0xfeb): undefined reference to `pthread_mutex_unlock'
          /usr/bin/i686-w64-mingw32-ld: /usr/lib/gcc/i686-w64-mingw32/9.4-posix/libgcc_eh.a(unwind-dw2-fde.o):(.text+0x10f5): undefined reference to `pthread_mutex_unlock'
          collect2: error: ld returned 1 exit status

  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `test-libusb` due to previous error

Any idea, what i'm doing wrong?
Also, with x86_64-pc-windows-gnu - all is fine.

UPD: Tried i686-w64-mingw-gcc and i686-w64-mingw-gcc-posix - same results.

Solved by:

  1. Add vendored feature flag
  2. Cross.toml
[target.i686-pc-windows-gnu.env]
passthrough = [
  "CFLAGS=-DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA",
]

According to https://stackoverflow.com/questions/37576454/gcc-mingw-compiler-does-not-recognize-cancelioex