libusb-sys
libusb-sys copied to clipboard
use build strategy from rust-openssl
On windows i've compiled libusb using msvc for x64.
To get libusb-rs and libusb-sys to compile I copied over and modified the build.rs from rust-openssl.
The approach is to allow the important bits to be overridden with environment variables, and falling back to pkg-config.
It should still work in a cross-compiling environment, but that'd be worth testing.
The env vars that I used with a built libusb were:
LIBUSB_INCLUDE_DIR=%HOME%\libusb\libusb LIBUSB_LIB_DIR=%HOME%\libusb\x64\Debug\dll
@cmsd2 Interesting approach. I like the idea of being able to compile on Windows without using pkg-config. I'll try to find some time to look at this. No promises on a timeline though. I'll need to block off a good chunk of free time to read through it, and I'll have to re-setup my Windows VM to test it out. Thanks for the PR.
Any updates on this? :)
I'd like to test it but I'm not very familiar with manipulation on github: what do I need to do? First, fork libusb-sys of course and then how do I merge this PR?
@Geobert PR is a request to merge one branch (possible from another repository) to another. On the top you can see that
cmsd2 wants to merge 1 commit into dcuddeback:master from cmsd2:master
So just download/clone the @cmsd2' s repository and try it.
If you want to test merged code, then add both repositories as git remotes, fetch both and try to merge into a single branch and test.
By the way, you can use vcpkg and vcpkg-rs on Windows, you won't need to set environment variables manually then.
I've hacked something by editing the build.rs in the registry folder
ooh. vcpkg looks useful. i would definitely admit that env vars for every -sys dependency would get a bit unweildy.
I just succesfully built a windows binary using dcuddeback/libusb-sys#5. if you want to build a project depending on libusb-rs, here are the steps required: Cargo.toml
[replace]
"libusb-sys:0.2.3"= { git = "https://github.com/cmsd2/libusb-sys/" }
then export LIBUSB_DIR
to point to the libusb installation. I installed libusb using [vcpkg](https://github.com/microsoft/vcpkg)
on windows.
and pointed to the installed package folder for libusb.
Tested on Windows 10 and FreeBSD for now.
The change provides a very nice and helpfull error message if libusb is not found. +1 for merging from here...
Any updates? I found it nearly awful by using library arranged by nix conventions. The total installation process has cost me a whole precious afternoon without any progress. I think this is not what our programming language in the 21st century would bring us.
Hello all. I try to maintenance fork of this library https://crates.io/crates/libusb1-sys Windows support by vcpkg or build bundled version.
I just wanted to say thanks for this, the fork was incredibly much easier to get building than this repository.
I used this configuration in my workspace Cargo.toml:
[patch.crates-io]
libusb-sys = { git = "https://github.com/[my clone of the fork]/libusb-sys", rev = "096f247" }
Edit: I spoke too soon. RLS works now, but the linker doesn't find something yet. Edit: This may be because of some compiler version incompatibility with the libusb binaries on my end, though.
Edit: rusb
works!