[ubuntu] How to install libusb in Ubuntu

I have a C program that have #include part in the header.

I have download libusb-1.0.0 to my computer. If I simply copy libusb-1.0.0 folder to the folder where my C program is, it will not work. Therefore, I think I have to somehow install libuse-1.-.- to the folder where my C program is. However, I do not how to install it.

Could anybody please help me. Thanks!

This question is related to ubuntu libusb

The answer is


Usually to use the library you need to install the dev version.

Try

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

This should work:

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

First,

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

updatedb && locate libusb.h.

Second, replace <libusb.h> with <libusb-1.0/libusb.h>.

update:

don't need to change any file.just add this to your Makefile.

`pkg-config libusb-1.0 --libs --cflags`

its result is that -I/usr/include/libusb-1.0 -lusb-1.0


"I need to install it to the folder of my C program." Why?

Include usb.h:

#include <usb.h>

and remember to add -lusb to gcc:

gcc -o example example.c -lusb

This work fine for me.


Here is what worked for me.

Install the userspace USB programming library development files

sudo apt-get install libusb-1.0-0-dev
sudo updatedb && locate libusb.h

The path should appear as (or similar)

/usr/include/libusb-1.0/libusb.h

Include the header to your C code

#include <libusb-1.0/libusb.h>

Compile your C file

gcc -o example example.c -lusb-1.0

you can creat symlink to your libusb after locate it in your system :

sudo ln -s /lib/x86_64-linux-gnu/libusb-1.0.so.0 /usr/lib/libusbx-1.0.so.0.1.0 

sudo ln -s /lib/x86_64-linux-gnu/libusb-1.0.so.0 /usr/lib/libusbx-1.0.so