Reputation: 41
Can somebody provide an example of using go-libusb
(or may be any other lib working with USB in Golang) .
libusb
There is an error:
Unresolved symbol: '_Cstruct_usb_device_descriptor'
Thank you.
Upvotes: 4
Views: 12139
Reputation: 461157
The go-libusb package by popons is a wrapper for the libusb-0.1 C-based USB driver. libusb-0.1 is "deprecated and unmaintained." [Source: libusb API version overview]
For using USB with Go, I'd recommend using a libusb 1.0 (source on GitHub) Go-driver, such as:
Both of the above Go drivers require having the C-version of libusb installed. To install on Windows, take a look at the libusb Windows driver installation instructions, which recommend using Zadig. You could also look at the SO question Installing libusb-1.0 on Windows 7, but the only answer appears to show how to install libusb-0.1 not libusb-1.0.
As a Windows user, I know this doesn't help you, but for OS X users, libusb can be installed using Homebrew:
$ brew install libusb
Upvotes: 3
Reputation: 99215
First you have to install libusb from http://www.libusb.org/wiki/libusb-win32, then either change // #include<usb.h>
to:
/*
#cgo LDFLAGS: -lusb
#include <usb.h>
*/
And descriptor _Cstruct_usb_device_descriptor
to descriptor C.struct_usb_device_descriptor
.
Or pull my fork from https://github.com/OneOfOne/go-libusb, I already sent a pull request with the changes.
Upvotes: 3