17

I want install libusb in ubuntu 14.04 LTS. I have downloaded libusb-1.0.9.tar.bz2 file from official site "http://libusb.org" but now I am unable to install it. I want to use libusb for Reliance usb for net connection.

As I am new to linux so please mention every command that I need to run in terminal.

Thanks in advance.

29

This is how you install libusb:

sudo apt-get install libusb-1.0-0-dev

Note that if you are using libusb in a C/C++ program you should include it the following way:

#include <libusb-1.0/libusb.h>

and not like this:

#include <libusb.h>

This is a common mistake that new users make.

Then finally you compile like this:

g++ source.cpp `pkg-config --libs --cflags libusb-1.0`
  • 1
    Not sure that you need to specify the version. sudo apt-get install libusb-dev worked fine for me. – Charlie Joynt Dec 6 '16 at 21:19
  • @CharlieJoynt In that case, how did you include libusb in your code and how did you compile it? – daltonfury42 Dec 7 '16 at 6:56
  • 1
    I came across this when trying to ./configure the libmtp library from Sourceforge. It was failing with an error saying the libusb library was missing. I resolved it with the command in my comment above. 'fraid it has been a long while since I wrote any C/C++ code myself. Since the OP only mentioned installing the package, I thought it might be useful to share my experience. – Charlie Joynt Dec 7 '16 at 9:09
  • I had a face-in-palm moment when I realized I had to omit "lib" from "libusb-1.0" in order to get ld to find the library. Just like -lz links libz.so, "-lusb-1.0" is the correct string. – stephen Apr 23 '18 at 18:53
3

Since you are new to linux I suggest running the below command from terminal to install libusb directly from the repository:

>sudo apt-get install libusb-1.0-0-dev

If you wish to continue with the archive you have downloaded, refer to the instructions in the below link:

http://www.linuxfromscratch.org/blfs/view/svn/general/libusb.html

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.