Thread: libusb: unable to compile

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    6

    libusb: unable to compile

    I am trying to compile a program that uses libusb. It is going to interface with the microsoft xbox on a board that uses a TI Omap processor. I am getting the following undefined references and I am not too sure what to do from the messages I am getting.
    Code:
    arm-none-linux-gnueabi-gcc -o kinectTestTry1 usb_libusb10.c
    /root/CodeSourcery/Sourcery_G++_Lite/bin/../arm-none-linux-gnueabi/libc/usr/lib/crt1.o: In function `_start':
    init.c:(.text+0x34): undefined reference to `main'
    /tmp/cckCeRjr.o: In function `fnusb_num_devices':
    usb_libusb10.c:(.text+0x134): undefined reference to `libusb_get_device_list'
    usb_libusb10.c:(.text+0x18c): undefined reference to `libusb_get_device_descriptor'
    usb_libusb10.c:(.text+0x1fc): undefined reference to `libusb_free_device_list'
    /tmp/cckCeRjr.o: In function `fnusb_init':
    usb_libusb10.c:(.text+0x240): undefined reference to `libusb_init'
    /tmp/cckCeRjr.o: In function `fnusb_shutdown':
    usb_libusb10.c:(.text+0x2dc): undefined reference to `libusb_exit'
    /tmp/cckCeRjr.o: In function `fnusb_process_events':
    usb_libusb10.c:(.text+0x318): undefined reference to `libusb_handle_events'
    /tmp/cckCeRjr.o: In function `fnusb_open_subdevices':
    usb_libusb10.c:(.text+0x394): undefined reference to `libusb_get_device_list'
    usb_libusb10.c:(.text+0x3f4): undefined reference to `libusb_get_device_descriptor'
    usb_libusb10.c:(.text+0x46c): undefined reference to `libusb_open'
    usb_libusb10.c:(.text+0x4a0): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0x4c4): undefined reference to `libusb_claim_interface'
    usb_libusb10.c:(.text+0x4e8): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0x4f8): undefined reference to `libusb_close'
    usb_libusb10.c:(.text+0x568): undefined reference to `libusb_open'
    usb_libusb10.c:(.text+0x59c): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0x5c0): undefined reference to `libusb_claim_interface'
    usb_libusb10.c:(.text+0x5e4): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0x5f4): undefined reference to `libusb_close'
    usb_libusb10.c:(.text+0x64c): undefined reference to `libusb_free_device_list'
    usb_libusb10.c:(.text+0x698): undefined reference to `libusb_release_interface'
    usb_libusb10.c:(.text+0x6a8): undefined reference to `libusb_close'
    usb_libusb10.c:(.text+0x6cc): undefined reference to `libusb_release_interface'
    usb_libusb10.c:(.text+0x6dc): undefined reference to `libusb_close'
    /tmp/cckCeRjr.o: In function `fnusb_close_subdevices':
    usb_libusb10.c:(.text+0x738): undefined reference to `libusb_release_interface'
    usb_libusb10.c:(.text+0x748): undefined reference to `libusb_close'
    usb_libusb10.c:(.text+0x778): undefined reference to `libusb_release_interface'
    usb_libusb10.c:(.text+0x788): undefined reference to `libusb_close'
    /tmp/cckCeRjr.o: In function `iso_callback':
    usb_libusb10.c:(.text+0x828): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0x8dc): undefined reference to `libusb_submit_transfer'
    usb_libusb10.c:(.text+0x90c): undefined reference to `fn_log'
    /tmp/cckCeRjr.o: In function `fnusb_start_iso':
    usb_libusb10.c:(.text+0xa30): undefined reference to `fn_log'
    usb_libusb10.c:(.text+0xa4c): undefined reference to `libusb_alloc_transfer'
    usb_libusb10.c:(.text+0xb08): undefined reference to `libusb_submit_transfer'
    usb_libusb10.c:(.text+0xb34): undefined reference to `fn_log'
    /tmp/cckCeRjr.o: In function `fnusb_stop_iso':
    usb_libusb10.c:(.text+0xbe0): undefined reference to `libusb_cancel_transfer'
    usb_libusb10.c:(.text+0xc14): undefined reference to `libusb_handle_events'
    usb_libusb10.c:(.text+0xc58): undefined reference to `libusb_free_transfer'
    /tmp/cckCeRjr.o: In function `fnusb_control':
    usb_libusb10.c:(.text+0xd0c): undefined reference to `libusb_control_transfer'
    collect2: ld returned 1 exit status
    From what I can collect these are issues with the fact that the compiler can't find the libusb library as I believe these functions are defined there. However I am not too sure how to link the library to the compiler or if this is even what is going on. A little light on the situation can help me tremendously on how to proceed.

    Thanks.
    -V

  2. #2
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    You probably need to actually link in the library. Including the header file only gives you declarations, not the actual code. If the library files are something like libusb.a or libusb.so, try using a -lusb (drop the lib prefix and .a/.so extension). Also, if it's not in a standard location for gcc to find, you my need to use the -L option to give it extra paths to search for libraries.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Include Compile Info
    By rkensparc in forum C Programming
    Replies: 1
    Last Post: 08-02-2007, 09:38 AM
  2. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  3. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  4. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  5. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM