I am trying to build a program that uses libusb and I get a lot of errors such as
i2cbrdg.c:84: error: implicit declaration of function ‘usb_init’
i2cbrdg.c:88: error: implicit declaration of function ‘usb_find_busses’
i2cbrdg.c:89: error: implicit declaration of function ‘usb_find_devices’
i2cbrdg.c:90: error: implicit declaration of function ‘usb_get_busses’
So I am trying to install libusb, but am having troubles doing so. I have installed libusb-dev and that appears to be okay. When I do dpkg -L libusb-dev, I get a list of directories. However, when I dpkg -L libusb, I get
Package `libusb' is not installed.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
I have done sudo apt-get install libusb-1.0 and that went okay. When I try to do it again I get the message
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libusb-1.0-0' for regex 'libusb-1.0'
Note, selecting 'libusb-1.0-0-dev' for regex 'libusb-1.0'
libusb-1.0-0-dev is already the newest version.
libusb-1.0-0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
I have also tried installing it with yum and it still says that it is not installed. I have downloaded the tar for the package and ran make on that, which also seemed to be okay (no explicit error messages). I don't really know what to try next. The dpkg message just keeps telling me its not installed. Can anyone give me a direction to go in? Any help is appreciated.
The libraries libusb 0.1 and libusb 1.0 are very different. You should decide now which one you want to use. I recommend libusb 1.0. The last time I checked, the libusb-dev
and libusb
packages install libusb 0.1, while the libusb-1.0-0-dev
package should install libusb 1.0, at least in Ubuntu.
After you install the desired library, you will need to #include
the header file in your C file and also add the right linker option.
For libusb 1.0, the include statement would be
#include <libusb-1.0/libusb.h>
and the linker option is
-lusb-1.0