• Home
  • Help
  • Search
  • Login
  • Register
Pages: [1]
Author Topic: Problem with libusb-1.0 plug  (Read 17783 times)

Karma: 0
Posts: 3

View Profile
« on: December 22, 2009, 04:03:22 PM »

Hi Everyone

I'm newbie to Linux, plug computers, but I'm totally sold on the plug.  I've been doing computer-based product development for a couple of decands, and I think the plug is a great idea with a future.

I'm porting an application from another Linux computer (Atom processor, Ubuntu 9.04).  My application talks to a Cypress chip over USB.  Right now it collects temperature information from a thermistor, but now that I know how to communicate from the Cypress to Linux, there will be more applications to come.  Linking on the Atom was no problem, but when I use this simple command line:

gcc Usbprogram.c -lusb-1.0 -lm (simplified from the Makefile)

I get:

/usr/bin/ld: cannot find -lusb-1.0

I got the same type of response when I tried to compile the libusb-0.1 program shown elsewhere on this forum.  I installed both libusb-1.0 and 0.1 using apt-get install.  Both have shared object links, but both give this same error.  I'm sure I'm missing something simple, but I can't figure it out.

I'm stuck, and I would appreciate any help you can offer.  Thank you!


Sr. Member

Karma: 4
Posts: 443

View Profile WWW
« Reply #1 on: December 22, 2009, 06:35:59 PM »

I installed both libusb-1.0 and 0.1 using apt-get install. 
You need libusb-*-dev.  libusb-* will install the run-time library (e.g. libusb-0.1.so.4).  libusb-*-dev is needed for the header files and linking link (libusb.so)


Karma: 0
Posts: 3

View Profile
« Reply #2 on: December 23, 2009, 07:56:54 PM »

Thanks very much, birdman.  That helped get past that problem, almost.  After I brought in the -dev files, gcc could not fine libusb.h, even though it was located in /usr/include/libusb-1.0/libusb.h.  I was able to get around that problem by simply moving this file to /usr/include/libusb.h.  I don't understand why, but it worked.  Next, the compiler was happy, but the linker complained:

/tmp/cc0M1IR3.o: In function `main':
FirstUsb.c:(.text+0x1a8): undefined reference to `libusb_init'
FirstUsb.c:(.text+0x1f0): undefined reference to `libusb_set_debug'
FirstUsb.c:(.text+0x208): undefined reference to `libusb_get_device_list'
FirstUsb.c:(.text+0x260): undefined reference to `libusb_get_device_descriptor'
FirstUsb.c:(.text+0x320): undefined reference to `libusb_open'
FirstUsb.c:(.text+0x370): undefined reference to `libusb_kernel_driver_active'
FirstUsb.c:(.text+0x940): undefined reference to `libusb_free_device_list'
FirstUsb.c:(.text+0x950): undefined reference to `libusb_close'
FirstUsb.c:(.text+0x958): undefined reference to `libusb_exit'
collect2: ld returned 1 exit status

This problem was cured by changing the gcc invocation line from:

gcc FirstUsb.c  -lusb-1.0 -lm


gcc FirstUsb.c  -L/lib/libusb-1.0.so.0 -lusb-1.0 -lm

I'd like to understand why I had to be so explicit about these two files, but for now the program compiled, linked, and seems to be working.

Thank you for your help, and my best wishes to all for a wonderful holiday--


Full Member

Karma: 7
Posts: 144

View Profile
« Reply #3 on: December 24, 2009, 04:53:25 AM »

The first problem (cannot find the .h file) was caused by not having the /usr/include/libusb-1.0 directory in the include search path.  It could have been solved by adding -I/usr/include/libusb-1.0 to the command line.  Your solution is just as valid. Smiley

The second problem was caused by not having a symolic link from libusb-1.0 to libusb-1.0.so.0 in the /lib directory.  I would have expected the apt-get install to do this for you.



Karma: 0
Posts: 3

View Profile
« Reply #4 on: December 24, 2009, 05:28:40 AM »

Thank you, Mark.  This helped.

I also found that I could take care of the first problem (can't find libusb.h) by changing my include list from:

#include <libusb.h>


#include <libusb-1.0/libusb.h>

Easy enough.  I didn't know about the -I feature of gcc, so thanks for that. Smiley



Karma: 0
Posts: 1

View Profile
« Reply #5 on: February 15, 2012, 02:04:56 AM »

Dear all,
I'm starting with the Dreamplug and also with Linux environment.
Actually I've a DreamPlug with preinstalled Debian Lenny with kernel and I like to start with some USB application because my goal will be control external device trough the USB bus.
As s first step I like to run a simple usb discover application. Regarding this point I've did a little search on the DreamPlug in order to understand what version of the libusb was installed:

dreamplug-debian:~# find / | grep libusb
find: File system loop detected; `/media/usb1' is part of the same file system loop as `/'.

regarding this point I think that the only version is the libusb-0.1.
Now I like to ask to some expert following questions:

I've read out here that there is also the libusb-1.0 version, is better to use this one or I can stay with the pre installed version libusb-0.1?

I'm not able to found any .h file to include into source file, from this post I've discovered that I need to install the dev version of the libusb.
By using the command:

apt-get install libusb-dev

I can install the dev version of the libusb-0.1 this is approx 14.7 MB in size.
I've to use this one or is better switch to the 1.0 release and then install this one?

From my little Linux knowledge I've used this command:

dreamplug-debian:~# apt-cache search libusb
libdjconsole-data - Hercules DJ Console access library - data files
libdjconsole-dev - Hercules DJ Console access library - development headers
libdjconsole0 - Hercules DJ Console access library
libftdi1 - Library to control and program the FTDI USB controller
libhid-dev - userspace USB HID development files
libhid0 - userspace USB HID access library
python-hid - Python wrapper for USB HID access library
libusb++-0.1-4c2 - userspace C++ USB programming library
libusb++-dev - userspace C++ USB programming library development files
libusb-0.1-4 - userspace USB programming library
libusb-dev - userspace USB programming library development files
spectools - Utilities for using the Wi-Spy USB spectrum analyzer hardware
libusbprog-dev - Development files for libusbprog
libusbprog0 - Library for programming the USBprog hardware
ekeyd-uds - Simtec Electronics UDEKEY01 Entropy Key Daemon (UDS variant)
libhpmud-dev - HP Multi-Point Transport Driver (hpmud) development libraries
libhpmud0 - HP Multi-Point Transport Driver (hpmud) run-time libraries
libusb-1.0-0-dev - userspace USB programming library development files
libusb-1.0-0 - userspace USB programming library

Could someone point me into the right direction?

Thanks in advance
The Grinch


Pages: [1]
Jump to: