Thread: cant include usb.h

  1. #1
    The Programming Dutchman
    Join Date
    Jan 2008
    Posts
    55

    cant include usb.h

    Hello Folks,

    I think this is a very nooby question but i cant figure this out. Just for fun i want to acces USB interfaces on a ubuntu system. now ik have installed USBLib-dev it is located on:

    Code:
    /usr/src/linux-headers-2.6.28-15-generic/include/linux/usb.h
    now i would like to use USB.h in one of my C++ applications. So i thought

    Code:
    #include <iostream>
    #include <usb.h> //also tried #include "usb.h"
    
    int main()
    {
    usb_init();
    return 0;
    }
    This gives me this error:
    Code:
    /media/DATA/Jelte/Programming/C++/USBLib-dev TEST/USBFindBusses/main.cpp|6|undefined reference to `usb_init'
    do you people see what i did wrong? is the including not correct or..?

    As IDE i use Code::blocks with gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3

    Thanks for your help.

    Jelte,
    Last edited by Jelte; 09-14-2009 at 12:17 PM.
    The Programming Dutchman

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Undefined reference is a linker error, not a compiler error.

    You need something like
    gcc prog.c -lusb
    assuming the library is called libusb.a

    That's just a guess, you can find out the real library name yourself.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. in a constant loop with threads using socket
    By kiros88 in forum C Programming
    Replies: 1
    Last Post: 08-21-2009, 06:34 PM
  2. debug assertion failed!
    By chintugavali in forum C Programming
    Replies: 4
    Last Post: 12-11-2007, 06:23 AM
  3. MFC include BS
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 10-31-2005, 12:44 PM
  4. help with finding lowest number entered
    By volk in forum C++ Programming
    Replies: 12
    Last Post: 03-22-2003, 01:21 PM
  5. #includes don't seem to be working
    By Inquirer in forum C++ Programming
    Replies: 12
    Last Post: 08-05-2002, 05:38 PM