Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C++ cross platform USB library? [closed]

I'm (going to be) writing an application in Qt that will run on the 3 main OSes (Windows, Linux and Mac). One of the features of this app is that it needs USB to talk to a piece of custom external hardware. Is there a cross-platform USB library available?

like image 762
Bojangles Avatar asked Oct 12 '10 16:10

Bojangles


People also ask

Why use libusb?

libusb is a C library that provides generic access to USB devices. It is intended to be used by developers to facilitate the production of applications that communicate with USB hardware. It is portable: Using a single cross-platform API, it provides access to USB devices on Linux, OS X, Windows, Android, OpenBSD, etc.

What is libusb Linux?

libusb is a library for USB device access from Linux, macOS, Windows, OpenBSD/NetBSD, Haiku, Solaris userspace, and WebAssembly via WebUSB. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).

What is libusb Dev?

libusb is an open source library that allows you to communicate with USB devices from user space. For more info, see the libusb homepage. This documentation is aimed at application developers wishing to communicate with USB peripherals from their own software.


2 Answers

Try libusb.

Supported operating systems: Linux, FreeBSD, NetBSD, OpenBSD, Darwin, MacOS X (and Windows, through the libusb-win32 project).

But you should note that it uses libusb0.sys kernel-mode driver on Windows, which is not WHQL certified and it could be a problem in 64-bit Windows 7 and Windows Server 2008 R2. Sorry, version 1.2.0.0 of libusb0.sys is digitally signed.

like image 148
Kirill V. Lyadvinsky Avatar answered Sep 29 '22 22:09

Kirill V. Lyadvinsky


I'd just like to update this post for anyone who is coming back to it nowadays...

Libusb (version 0.1) has since been deprecated. The modern standard is to use libusb-1.0 or libusbx.

Personally, I think there are many reasons to use libusbx. It was written by frustrated libusb-0.1 developers who wanted a more frequent update cycle and better bug maintenance system.

My reasons for suggesting libusbx are as follows:

  • does not require sudo access
  • worked much better for me out of the box with reading incoming messages
  • better support and more frequent responses to bugs/issues
  • async and synchronous support for sending/receiving messages

Granted, libusb-1.0 does support async/sync reporting... but the philosophy behind libusbx is much more appealing and the documentation is better.

So it's totally up to you, if you or whoever would still like to know some more about the libraries, the history is very easy to find online. You can also see this stack question for some more info on the immediate subject.

like image 35
eatonphil Avatar answered Sep 30 '22 00:09

eatonphil