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

use build strategy from rust-openssl #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cmsd2
Copy link

@cmsd2 cmsd2 commented Feb 14, 2017

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

@dcuddeback
Copy link
Owner

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

@Boscop
Copy link

Boscop commented Aug 21, 2017

Any updates on this? :)

@Geobert
Copy link

Geobert commented Apr 24, 2018

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?

@pravic
Copy link

pravic commented Apr 25, 2018

@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
Copy link

pravic commented Apr 25, 2018

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

@Geobert
Copy link

Geobert commented Apr 25, 2018

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

@cmsd2
Copy link
Author

cmsd2 commented Apr 26, 2018

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

@TypedLambda
Copy link

TypedLambda commented Nov 9, 2018

I just succesfully built a windows binary using #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...

@luojia65
Copy link

luojia65 commented Apr 16, 2019

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.

@a1ien
Copy link

a1ien commented Aug 5, 2019

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

@Tamschi
Copy link

Tamschi commented Dec 12, 2019

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!

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

Successfully merging this pull request may close these issues.

9 participants