title: problems compiling c code with libusb on linux
body: <p>I'm trying to use libusb for a project but i'm unable to get the library working properly. Here is some source code i'm trying to compile. It doesn't do anything special. It's just a dummy program that gets the USB driver list then frees it. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;usb.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(int argc, char *argv[]){
  
       struct libusb_device **devs;
       struct libusb_context *context = NULL;
       size_t list;
       size_t i;
       int ret;
  
     ret = libusb_init(&amp;context);
  
     if(ret &lt; 0)
        {
          perror("libusb_init");
          exit(1);
        }
  
     list = libusb_get_device_list(context, &amp;devs);
  
     if(list &lt; 0)
     {
  
         fprintf(stderr, "error in getting device list\n");
         libusb_free_device_list(devs, 1);
         libusb_exit(context);
         exit(1);
     }
  
  
     libusb_free_device_list(devs, 1);
     libusb_exit(context);
  
    return 0;
  
  }
  </code></pre>
  
  <p>I compile with  </p>
  
  <p>gcc -o test test.c -lusb</p>
  
  <p>I get the error</p>
  
  <pre><code>/tmp/cc2hwzii.o: in function 'main:
  test.c:(.text+0x24): undefined reference to 'libusb_init'
  test.c:(.text+0x59): undefined reference to 'libusb_get_device_list'
  test.c:(.text+0x8e): undefined reference to 'libusb_free_device_list'
  test.c:(.text+0x9f): undefined reference to 'libusb_exit'
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>I'm running ubuntu 14.04.3 
  I've installed libusb by sudo apt-get install libusb-dev
  I've searched for my header file and it is called usb.h
  I've looked to make sure I have the correct flag and it's -lusb</p>
  
  <p>any ideas? I'd appreciate the help. If any more information is needed just ask.</p>