libusb-sys icon indicating copy to clipboard operation
libusb-sys copied to clipboard

use build strategy from rust-openssl

Open cmsd2 opened this issue 7 years ago • 11 comments

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 avatar Feb 14 '17 21:02 cmsd2

@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.

dcuddeback avatar Mar 05 '17 03:03 dcuddeback

Any updates on this? :)

Boscop avatar Aug 21 '17 08:08 Boscop

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 avatar Apr 24 '18 21:04 Geobert

@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.

pravic avatar Apr 25 '18 17:04 pravic

By the way, you can use vcpkg and vcpkg-rs on Windows, you won't need to set environment variables manually then.

pravic avatar Apr 25 '18 18:04 pravic

I've hacked something by editing the build.rs in the registry folder

Geobert avatar Apr 25 '18 18:04 Geobert

ooh. vcpkg looks useful. i would definitely admit that env vars for every -sys dependency would get a bit unweildy.

cmsd2 avatar Apr 26 '18 08:04 cmsd2

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...

TypedLambda avatar Nov 09 '18 09:11 TypedLambda

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.

luojia65 avatar Apr 16 '19 09:04 luojia65

Hello all. I try to maintenance fork of this library https://crates.io/crates/libusb1-sys Windows support by vcpkg or build bundled version.

a1ien avatar Aug 05 '19 18:08 a1ien

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!

Tamschi avatar Dec 12 '19 13:12 Tamschi