Как связать или перекрестно скомпилировать libusb для MIPS, требуемого hidapi crate? (MT7688)

Мне удалось кросс-компилировать мой проект Rust для MIPS на macOS с использованием контейнера Docker, но теперь мне нужно рассказать Cargo, как связать libusb для моей цели. У меня есть только одна зависимость, hidapi = "0.5.0",

Бег cargo build --target=mipsel-unknown-linux-musl --verbose броски:

error: linking with `mipsel-openwrt-linux-gcc` failed: exit code: 1
  |
  = note: "mipsel-openwrt-linux-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-L" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.1a2n7mm6fj2rpycd.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.1qee5wltv2k8uahi.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.1wmrux2jbe4gjyy1.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.20tzizcgkouukpe7.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.27vi9ix5re3pua8i.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.2i5gg09te0pdjvrz.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.3oh03dybkj9hx3t9.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.3ounhhxngogi68h7.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.43dnkfujw49am5m7.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.49sec4q58p521s9j.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.4uzr4mhu1knzsadu.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.524rxs8j4jcxbyc9.rcgu.o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.5f8kd5qe8f75me5w.rcgu.o" "-o" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f" "/source/target/mipsel-unknown-linux-musl/debug/deps/led-9a0ed79de972ea7f.20mhl4i0rs2dire4.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/source/target/mipsel-unknown-linux-musl/debug/deps" "-L" "/source/target/debug/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/source/target/mipsel-unknown-linux-musl/debug/build/hidapi-dbf15a335a9b28a3/out" "-L" "/source/target/mipsel-unknown-linux-musl/debug/build/backtrace-sys-1dbada783d743007/out" "-L" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib" "-Wl,-Bstatic" "/source/target/mipsel-unknown-linux-musl/debug/deps/libhidapi-ec0753230d0b19c8.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/libfailure-a94ee1c682d2f0a3.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/libbacktrace-33e85df5fb2d7d5a.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/libbacktrace_sys-be666e80fd389ebb.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/librustc_demangle-bcba2691db8bbeb8.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/libcfg_if-259032110470e3d1.rlib" "/source/target/mipsel-unknown-linux-musl/debug/deps/liblibc-1744699d5cfa3db6.rlib" "-Wl,--start-group" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libstd-f298969233258089.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libpanic_unwind-88ee504c04c324dd.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libbacktrace_sys-b924d1fbd840245f.rlib" "/tmp/rustcdIxI2n/libunwind-34111617eadd05ed.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/librustc_demangle-61e6f5199a2cd82a.rlib" "/tmp/rustcdIxI2n/liblibc-c4b8d92e6a659439.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/liballoc-b7742f4590e2546c.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/librustc_std_workspace_core-775acdfa8a94f296.rlib" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libcore-d81da9d45935cab5.rlib" "-Wl,--end-group" "/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libcompiler_builtins-69c753153c9dee70.rlib" "-Wl,-Bdynamic" "-lusb-1.0" "-lgcc_s" "-lc"
  = note: mipsel-openwrt-linux-musl-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
          mipsel-openwrt-linux-musl-gcc.bin: warning: environment variable 'STAGING_DIR' not defined
          /toolchain/bin/../lib/gcc/mipsel-openwrt-linux-musl/5.3.0/../../../../mipsel-openwrt-linux-musl/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libusb-1.0.so when searching for -lusb-1.0
          /toolchain/bin/../lib/gcc/mipsel-openwrt-linux-musl/5.3.0/../../../../mipsel-openwrt-linux-musl/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libusb-1.0.a when searching for -lusb-1.0
          /toolchain/bin/../lib/gcc/mipsel-openwrt-linux-musl/5.3.0/../../../../mipsel-openwrt-linux-musl/bin/ld: cannot find -lusb-1.0
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `led`.

Как я понял, мне нужно сообщить Cargo какой родной libusb.* библиотеки для ссылки, или кросс-компиляция libusb с нуля, но это для меня загадочно.

Какие библиотеки мне нужны и как заставить Rust использовать их для этого проекта?

Обновление: мне удалось скомпилировать libusb для MIPS и вывести правильный libusb-1.0.a файлы и т.д., но я все еще не могу заставить Rust использовать нужные библиотеки, несмотря на то, что .cargo/config а также PKG_CONFIG_LIBDIR пути.

0 ответов

Другие вопросы по тегам