| 1 |
= Building Ruby-USB on Windows |
| 2 |
|
| 3 |
The binaries will work with the Ruby one-click installer, but we have to build everything |
| 4 |
with MinGW. This also means we need to build our own Ruby with MinGW. |
| 5 |
|
| 6 |
== Author of README.win32 |
| 7 |
|
| 8 |
Aslak Hellesøy <aslak.hellesoy@gmail.com> |
| 9 |
|
| 10 |
== Installing prerequisites |
| 11 |
* MinGW and MSYS: http://www.mingw.org/ (MinGW installer and msysCORE-1.0.11-2007.01.19-1.tar.bz2) |
| 12 |
* LibUsb-Win32: http://libusb-win32.sourceforge.net/ |
| 13 |
* Ruby sources |
| 14 |
|
| 15 |
== Building Ruby with MinGW |
| 16 |
put MSYS and MinGW bin on the path, for example: |
| 17 |
SET PATH=C:\MinGW\bin;C:\msys\bin;%PATH% |
| 18 |
|
| 19 |
cd to ruby sources |
| 20 |
|
| 21 |
sh configure --with-winsock2 |
| 22 |
make |
| 23 |
make install |
| 24 |
|
| 25 |
You now have a Ruby under c:\usr\local\bin\ruby.exe Try it: |
| 26 |
|
| 27 |
C:\usr\local\bin\ruby --version |
| 28 |
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mingw32] |
| 29 |
(note the [i386-mingw32]) |
| 30 |
|
| 31 |
Now, copy zlib.so and openssl.so from your prebuilt Ruby to the one you built yourself, |
| 32 |
your own build won't have it. This is needed in order for Rubygems to work. |
| 33 |
|
| 34 |
Now you must install rubygems. After you have done that, install hoe: |
| 35 |
\usr\local\bin\gem install hoe |
| 36 |
You may have to comment out the line in hoe.rb that has `which dot` |
| 37 |
|
| 38 |
== Prepare for building the native extensions |
| 39 |
We must copy the libusb library and header file into ruby-usb. |
| 40 |
First, cd to the toplevel dir (the directory of this file) |
| 41 |
|
| 42 |
cp "C:\Program Files\LibUSB-Win32\lib\msvc\libusb.lib" ext\usb.lib |
| 43 |
cp "C:\Program Files\LibUSB-Win32\include\usb.h" ext |
| 44 |
|
| 45 |
== Build the gem with binary extensions |
| 46 |
\usr\local\bin\rake clean compile gem INLINE=1 FORCE_PLATFORM=mswin32 |
| 47 |
|
| 48 |
== Install the gem in your official ruby (the one from Ruby one-click installer) |
| 49 |
gem install pkg\ruby-usb-0.1.1-x86-mswin32.gem |
| 50 |
|
| 51 |
== Test that it works in your official ruby |
| 52 |
> irb |
| 53 |
irb(main):001:0> require 'usb' |
| 54 |
=> true |
| 55 |
irb(main):002:0> puts USB.devices.inspect |
| 56 |
[#<USB::Device bus-0/\\.\libusb0-0001--0x0a5c-0x2110 0a5c:2110 Broadcom Corp BCM2045B ? (Bluetooth)>, #<USB::Device bus-0/\\.\libusb0-0002--0x0483-0x2016 0483:2016 STMicroelectronics Biometric Coprocessor ? (Vendor specific (00,00))>] |