Can't build simple app with libusb-dev

Bug #920948 reported by mariodebian
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libusb (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

In Ubuntu Precise (12.04) can build this simple app:

#include <stdio.h>
#include <usb.h>
int main(){
    usb_init();
    printf("Hello world!\n");
    return 0;
}

$ gcc -Wall -lusb test.c -o test
/tmp/ccPHsjM4.o: In function `main':
test.c:(.text+0xa): undefined reference to `usb_init'
collect2: ld returned 1 exit status

$ gcc -Wall -L/usr/lib/i386-linux-gnu -lusb test.c -o test
/tmp/cc7e0ElV.o: In function `main':
test.c:(.text+0xa): undefined reference to `usb_init'
collect2: ld returned 1 exit status

In Debian unstable ( libusb-dev 2:0.1.12-20) builds and run fine.
In Ubuntu Lucid 10.04 (libusb-dev 2:0.1.12-14ubuntu0.2) builds and run fine.

Revision history for this message
Daniel Letzeisen (dtl131) wrote :

Have you tried using libusb-1.0.0-dev , libusb.h and libusb_init() ?

Revision history for this message
mariodebian (mariodebian) wrote :

@Dave this is not valid solution, I have a more complex app and I can't change libusb0 => libusb1

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libusb (Ubuntu):
status: New → Confirmed
Revision history for this message
Jonathan Thomas (echidnaman) wrote :

Newer versions of GCC require the linker flags to be placed after the objects to be linked. (So with this example, the proper command to build it is "gcc -Wall test.c -lusb -o test")

This bit me too for a while. :(

Changed in libusb (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.