45

I want to 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.

1

2 Answers 2

66

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 I was making. Finally you compile like this:

g++ source.cpp `pkg-config --libs --cflags libusb-1.0`
6
  • 1
    Not sure that you need to specify the version. sudo apt-get install libusb-dev worked fine for me. Dec 6, 2016 at 21:19
  • @CharlieJoynt In that case, how did you include libusb in your code and how did you compile it? Dec 7, 2016 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. Dec 7, 2016 at 9:09
  • 1
    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, 2018 at 18:53
  • @CharlieJoynt You should specify the version, or at least be aware if your program needs a particular version, because on some platforms libusb-dev is not the same as libusb-1.0-0-dev (e.g. Raspberry Pi).
    – Josh
    Feb 12, 2019 at 0:03
6

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .