Open TomasHubelbauer opened 7 years ago
I got it working on windows with a .cargo/config build script override and the dll from here: https://sourceforge.net/projects/libusb/files/
[target.x86_64-pc-windows-msvc.'usb-1.0']
rustc-link-search = ['D:\libs\64bit']
rustc-link-lib = ['libusb-1.0']
@TomasHubelbauer When I built this library (March 2015), rustup didn't exist, so I've not tested with the toolchains provided by rustup. The documented way to install Rust on Windows at that time was to use MSYS2. I documented the steps that worked for me in https://github.com/dcuddeback/libusb-sys/issues/4. There's also a PR for libusb-sys that borrows a build strategy from rust-openssl, which is supposed to work with MSVC as well: https://github.com/dcuddeback/libusb-sys/pull/5. You may want to give that a try. I haven't had time to test it myself. I'm not as comfortable on Windows as I am on Unix, so I could use help solving Windows build issues. If you happen to try https://github.com/dcuddeback/libusb-sys/pull/5, I'd appreciate some feedback on whether or not it solves your issue.
@TomasHubelbauer Thank you for your detailed report. This report helped me get my instance compiling with libusb. Specifically the pkg-config portion helped me the most.
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 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...
@TomasHubelbauer Thank you for your detailed report!! the best libusb/windows docs I've found! Thank you!
@TomasHubelbauer, use the static lib, and modify the last line of libusb.pc to:
Libs: -L${libdir} -lusb-1.0
There is my libusb.pc:
prefix=C:\MinGW
exec_prefix=${prefix}
includedir=${prefix}/include/libusb-1.0
libdir=${exec_prefix}/lib/libusb
Name: libusb
Description: libusb
Version: 1.0
Cflags: -I${includedir}
Libs: -L${libdir} -lusb-1.0
libdir has only one file that is a copy of libusb-1.0.24.7z\MinGW64\static\libusb-1.0.a
.
Seeing @bitbegin's issue (#17), I tried to use the GNU toolchain, but ended up with an error.
I'm on Windows 10 Home 64 bit.
rustup override set stable-x86_64-pc-windows-gnu
pkg-config-lite
%PATH%
topkg-config-lite-0.28-1\bin
%PKG_CONFIG_PATH%
topkg-config-lite-0.28-1\libs
I createdpkg-config
was working usingpkg-config -v
libusb
for Windows by clicking Downloads > Latest Windows binarieslibusb.pc
file in thePKG_CONFIG_PATH
directory:Here's what
pkg-config --libs --cflags libusb-1.0
spits out for me:-IC:/Users/Tom/Desktop/pkg-config-lite-0.28-1/libs/libusb/include/libusb-1.0 -LC:/Users/Tom/Desktop/pkg-config-lite-0.28-1/libs/libusb/MinGW64/dll -llibusb-1.0
I am using this example code based on what's in the
README.md
file of this repository:Running
cargo run
then links just fine and runs the binary which subsequently fails with the3221225781
exit code, which is0xC0000135
, which meansSTATUS_DLL_NOT_FOUND
.I suspect this is because I am using the
dll
directory, not thestatic
directory, but with that one, I just get linked errors.@dcuddeback would you be able to advise here?