title: Undefined reference to `libusb_handle_events_completed`
body: <p>I'm trying to compile <a href="https://code.google.com/p/mphidflash/" rel="nofollow">mphidflash</a> on Debian (Jessie) after re-writing the low-level USB interface to talk to libhidapi-libusb instead of libhid (which is no longer supported on Debian) but I'm getting some compiler errors that I'm not sure what do to with.</p>
  
  <p>These are my includes in <code>usb-linux.c</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;usb.h&gt;
  #include &lt;hidapi/hidapi.h&gt;
  #include "mphidflash.h"
  #include &lt;errno.h&gt;
  </code></pre>
  
  <p>and here are the commands I've tried which error:</p>
  
  <pre><code>$ gcc main.o hex.o usb-linux.o -lusb -lhidapi-libusb -o mphidflash
  /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libhidapi-libusb.so: undefined reference to `libusb_handle_events_completed'
  collect2: error: ld returned 1 exit status
  
  
  $ gcc main.o hex.o usb-linux.o /usr/lib/x86_64-linux-gnu/libhidapi-libusb.a -lusb -lhidapi-libusb -o mphidflash
  /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libhidapi-libusb.a(hid.o): undefined reference to symbol 'libusb_detach_kernel_driver'
  //usr/local/lib/libusb-1.0.so.0: error adding symbols: DSO missing from command line
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>Basically, I'm getting an <code>undefined reference to symbol 'libusb_detach_kernel_driver'</code> which suggests that I'm including the libusb library incorrectly but I've no idea what else to try.</p>