简体   繁体   中英

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!

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

Try

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

这应该有效:

# 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

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

My two cents: libusbx is pretty active lately and works like a charm on Debian GNU/Linux (should be the same for Ubuntu). Then

$ ./configure && make && make install && sudo ldconfig

will drop libusbx to /usr/local .

"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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM