Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install libusb in Ubuntu

Tags:

ubuntu

libusb

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!

like image 676
John Avatar asked Jan 31 '11 16:01

John


People also ask

What is libusb in Linux?

libusb is a C library that provides generic access to USB devices. It is intended to be used by developers to facilitate the production of applications that communicate with USB hardware. It is portable: Using a single cross-platform API, it provides access to USB devices on Linux, macOS, Windows, etc.

How do I install libusb on Windows?

To install libusb on Windows 7 download the bin package for libusb-win32 (this link points to version 1.2. 6). Then go to the bin directory and run inf-wizard.exe . Here is where you can customize and generate an INF installation file for your device, as well as the installer executables.


4 Answers

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

Try

sudo apt-get install libusb-1.0-0-dev
like image 79
Gazler Avatar answered Oct 08 '22 16:10

Gazler


This should work:

# apt-get install libusb-1.0-0-dev
like image 30
Ton van den Heuvel Avatar answered Oct 08 '22 16:10

Ton van den Heuvel


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

like image 20
kangear Avatar answered Oct 08 '22 16:10

kangear


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
like image 25
mrbean Avatar answered Oct 08 '22 15:10

mrbean