Fixing libusb-1.0 detection

Today while compiling dfu-utils I faced this error message:

checking for USB... no
configure: error: *** Required libusb-1.0 >= 1.0.0 not installed ***

Even after to install libusb-1.0:

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

the error remains…

Then I decided to take a look at “./configure –help” and saw these options:

  USB_CFLAGS  C compiler flags for USB, overriding pkg-config
  USB_LIBS    linker flags for USB, overriding pkg-config

Let to check where libusb was installed:

$ dpkg -L libusb-1.0-0-dev
...
/usr/include/libusb-1.0/libusb.h
/usr/lib/x86_64-linux-gnu/libusb-1.0.so

Then I decided to setup USB_CFLAGS and USB_LIBS this way:

$ export USB_CFLAGS="-I/usr/include/libusb-1.0"
$ export USB_LIBS="-L/usr/lib/x86_64-linux-gnu"

Now the ./configure executed correctly, but while executing make I got these issues:

  CCLD   dfu-util
main.o: In function `find_dfu_if':
/home/alan/Downloads/dfu-util-0.7/src/main.c:67: undefined reference to `libusb_get_device_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:72: undefined reference to `libusb_get_config_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:114: undefined reference to `libusb_free_config_descriptor'
main.o: In function `iterate_dfu_devices':
/home/alan/Downloads/dfu-util-0.7/src/main.c:284: undefined reference to `libusb_get_device_list'
/home/alan/Downloads/dfu-util-0.7/src/main.c:294: undefined reference to `libusb_get_device_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:291: undefined reference to `libusb_get_bus_number'
/home/alan/Downloads/dfu-util-0.7/src/main.c:292: undefined reference to `libusb_get_device_address'
/home/alan/Downloads/dfu-util-0.7/src/main.c:311: undefined reference to `libusb_free_device_list'
/home/alan/Downloads/dfu-util-0.7/src/main.c:307: undefined reference to `libusb_free_device_list'
main.o: In function `list_dfu_interfaces':
/home/alan/Downloads/dfu-util-0.7/src/main.c:231: undefined reference to `libusb_get_device_list'
/home/alan/Downloads/dfu-util-0.7/src/main.c:238: undefined reference to `libusb_free_device_list'
main.o: In function `get_alt_name':
/home/alan/Downloads/dfu-util-0.7/src/main.c:188: undefined reference to `libusb_get_config_descriptor_by_value'
/home/alan/Downloads/dfu-util-0.7/src/main.c:205: undefined reference to `libusb_free_config_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:201: undefined reference to `libusb_get_string_descriptor_ascii'
/home/alan/Downloads/dfu-util-0.7/src/main.c:198: undefined reference to `libusb_open'
main.o: In function `get_cached_extra_descriptor':
/home/alan/Downloads/dfu-util-0.7/src/main.c:500: undefined reference to `libusb_get_config_descriptor_by_value'
/home/alan/Downloads/dfu-util-0.7/src/main.c:524: undefined reference to `libusb_free_config_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:524: undefined reference to `libusb_free_config_descriptor'
main.o: In function `main':
/home/alan/Downloads/dfu-util-0.7/src/main.c:721: undefined reference to `libusb_init'
/home/alan/Downloads/dfu-util-0.7/src/main.c:728: undefined reference to `libusb_set_debug'
/home/alan/Downloads/dfu-util-0.7/src/main.c:758: undefined reference to `libusb_open'
/home/alan/Downloads/dfu-util-0.7/src/main.c:959: undefined reference to `libusb_claim_interface'
/home/alan/Downloads/dfu-util-0.7/src/main.c:965: undefined reference to `libusb_set_interface_alt_setting'
/home/alan/Downloads/dfu-util-0.7/src/main.c:1085: undefined reference to `libusb_get_device_descriptor'
main.o: In function `usb_get_any_descriptor':
/home/alan/Downloads/dfu-util-0.7/src/main.c:439: undefined reference to `libusb_get_device'
/home/alan/Downloads/dfu-util-0.7/src/main.c:445: undefined reference to `libusb_get_active_config_descriptor'
/home/alan/Downloads/dfu-util-0.7/src/main.c:455: undefined reference to `libusb_free_config_descriptor'
main.o: In function `libusb_get_descriptor':
/usr/include/libusb-1.0/libusb.h:1342: undefined reference to `libusb_control_transfer'
main.o: In function `main':
/home/alan/Downloads/dfu-util-0.7/src/main.c:1169: undefined reference to `libusb_close'
/home/alan/Downloads/dfu-util-0.7/src/main.c:1170: undefined reference to `libusb_exit'
/home/alan/Downloads/dfu-util-0.7/src/main.c:802: undefined reference to `libusb_claim_interface'
/home/alan/Downloads/dfu-util-0.7/src/main.c:808: undefined reference to `libusb_set_interface_alt_setting'
/home/alan/Downloads/dfu-util-0.7/src/main.c:834: undefined reference to `libusb_release_interface'
/home/alan/Downloads/dfu-util-0.7/src/main.c:862: undefined reference to `libusb_release_interface'
/home/alan/Downloads/dfu-util-0.7/src/main.c:864: undefined reference to `libusb_close'
/home/alan/Downloads/dfu-util-0.7/src/main.c:900: undefined reference to `libusb_open'
/home/alan/Downloads/dfu-util-0.7/src/main.c:1163: undefined reference to `libusb_reset_device'
/home/alan/Downloads/dfu-util-0.7/src/main.c:840: undefined reference to `libusb_reset_device'
main.o: In function `libusb_get_descriptor':
/usr/include/libusb-1.0/libusb.h:1342: undefined reference to `libusb_control_transfer'
main.o: In function `main':
/home/alan/Downloads/dfu-util-0.7/src/main.c:867: undefined reference to `libusb_exit'
dfuse.o: In function `dfuse_download':
/home/alan/Downloads/dfu-util-0.7/src/dfuse.c:146: undefined reference to `libusb_control_transfer'
dfuse.o: In function `dfuse_upload':
/home/alan/Downloads/dfu-util-0.7/src/dfuse.c:123: undefined reference to `libusb_control_transfer'
dfu.o: In function `dfu_abort':
/home/alan/Downloads/dfu-util-0.7/src/dfu.c:321: undefined reference to `libusb_control_transfer'
dfu.o: In function `dfu_get_state':
/home/alan/Downloads/dfu-util-0.7/src/dfu.c:288: undefined reference to `libusb_control_transfer'
dfu.o: In function `dfu_clear_status':
/home/alan/Downloads/dfu-util-0.7/src/dfu.c:257: undefined reference to `libusb_control_transfer'
dfu.o:/home/alan/Downloads/dfu-util-0.7/src/dfu.c:220: more undefined references to `libusb_control_transfer' follow
collect2: ld returned 1 exit status
make[2]: *** [dfu-util] Error 1

Then I found this suggestion to include “-lusb-1.0” to USB_LIBS:

$ export USB_LIBS="-L/usr/lib/x86_64-linux-gnu -lusb-1.0"
$ make distclean
$ ./configure
$ make
$ sudo make install

Now everything worked fine.

Advertisements

4 thoughts on “Fixing libusb-1.0 detection

  1. Hi Michael,
    You are welcome! It is nice to know this issue has been fixed.
    Why do you still using Mint 13? (Just my curiosity)
    Yes, Ubuntu 12.04 base is LTS, but using a recent distro you will get more up-to-date programs. Nice to have a Sparkfunner here 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s