Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on windows #4

Closed
rukai opened this issue Jun 23, 2016 · 2 comments
Closed

Building on windows #4

rukai opened this issue Jun 23, 2016 · 2 comments

Comments

@rukai
Copy link

rukai commented Jun 23, 2016

I've been enjoying using this library on Linux. (through libusb-rs)

However I've been trying to set it up on windows with no success.
I don't really understand the windows ecosystem properly, I've tried installing pkg-config and libusb via msys2 but that didn't change anything.
Specifically I am getting the error.

error: failed to run custom build command for `libusb-sys v0.2.2`
Process didn't exit successfully: `C:\Users\Rukai\Desktop\libusb-test-project\target\debug\build\libusb-sys-36fda20739032e96\build-script-build` (exit code: 101)
--- stderr
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: "Failed to run `\"pkg-config\" \"--libs\" \"--cflags\" \"libusb-1.0\"`: The system cannot find the file specified. (os error 2)"', ../src/libcore\result.rs:746
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Could you provide some step-by-step instructions for setting this up on windows, in the readme or the github wiki? I'm sure I'm not the only one who would benefit from this. Thanks.

@dcuddeback
Copy link
Owner

@rukai I had to reinstall msys2 to refresh my memory, but here's what worked for me:

  • Install msys2-x86_64 from https://msys2.github.io/.
  • Install Rust for the x86_64-pc-windows-gnu target triple. It seems that pkg-config complains about cross-compilation when targeting the -msvc ABI from within msys2.
  • Launch mingw64 shell:
    • pacman -Sy pacman-mirrors
    • pacman -S mingw64/mingw-w64-x86_64-pkg-config
    • pacman -S msys/pkg-config
    • pacman -S mingw64/mingw-w64-x86_64-libusb

At this point, you should be able to see libusb in the output from pkg-config --list-all. If you can, cargo build should work.

The error message you pasted sounds like it's not finding a pkg-config binary. Try installing pacman -S msys/pkg-config. I think that's the one that worked for me. I think another key is being consistent about choosing 64-bit and 32-bit, since both are options for msys2, the shell, and the packages in pacman.

@dcuddeback
Copy link
Owner

I hope those instructions help. Closing since the question has been answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants