Libusb and how to use its packages in Ubuntu

I installed libusb using the following command. I'm not sure if it was right or not, and the team was

sudo apt-get install libusb-dev

As soon as I installed (and I'm not sure if it is installed or not, because I'm a beginner user of Ubuntu), I want to know how to use the library because I write example code that uses <libusb.h>, but when I compile this c ++ file with

g++ test_libusb.cpp

which produces the following error,

test_libusb.cpp: 2: 20: fatal error: libusb.h: such a file or directory compiler did not complete.

I do not know what to do. I can not find a source on the Internet to figure this out ...

I want to know two things here:

  • How to add libusb library in C / C ++ so that I can use <libusb.h>?
  • ? , , libusb...
+5
4
+6

:

#include <libusb-1.0/libusb.h>

:

g++ main.cpp -o main -lusb-1.0
+8

#include <usb.h>. "Lib" Linux, "foo" foo.h libfoo-dev Debian -lfoo, libfoo.a libfoo.so.

+5

In fact, at least Debian 7.4 (wheezy) and probably Ubuntu have two different libusb packages: libusb-dev(0.1.12-20 + nmu1) and libusb-1.0-0-dev(1.0.11-1). Vaguely, they can both be installed at the same time and provide header files in different places:

$ dpkg -L libusb-dev|grep /usr/include
/usr/include
/usr/include/usb.h
$ dpkg -L libusb-1.0-0-dev|grep /usr/include
/usr/include
/usr/include/libusb-1.0
/usr/include/libusb-1.0/libusb.h
+5
source

All Articles