C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-02-2008, 07:58 PM   #1
Registered User
 
Join Date: Dec 2008
Posts: 2
libusb headache

Hi

First post, so do be gentle.

I am trying to get libusb to work w/ my compiler and all seems fine until I try something like:

Code:
#include <usb.h>

int main(int argc, char **argv) {
	struct usb_bus *busses;
   	usb_init();
   	usb_find_busses();
   	usb_find_devices();
   	busses = usb_get_busses();
	return 0;
}
I'm on Ubuntu 8.04 (Hardy Heron), and using Eclipse 3.2.2. I can compile other C code just fine (having a great time w/ GTK+). I can see that usb.h is in my `Includes` folder i.e., `/usr/include/usb.h` but I get a bunch of messages when I attempt to compile like:

Quote:
undefined reference to `usb_init'
I guess it is something to do w/ the Linker as that is where the error gets thrown (see below). But how would I go about resolving that?

Code:
**** Build of configuration Debug for project usb ****

make -k all 
Building file: ../main.c
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.c"
Finished building: ../main.c
 
Building target: usb
Invoking: GCC C Linker
gcc  -o"usb"  ./main.o   
./main.o: In function `main':
/home/cbee/c/usb/Debug/../main.c:6: undefined reference to `usb_init'
/home/cbee/c/usb/Debug/../main.c:7: undefined reference to `usb_find_busses'
/home/cbee/c/usb/Debug/../main.c:8: undefined reference to `usb_find_devices'
/home/cbee/c/usb/Debug/../main.c:9: undefined reference to `usb_get_busses'
collect2: ld returned 1 exit status
make: *** [usb] Error 1
make: Target `all' not remade because of errors.
Build complete for project usb
cbee is offline   Reply With Quote
Old 12-02-2008, 08:07 PM   #2
subminimalist
 
MK27's Avatar
 
Join Date: Jul 2008
Location: NYC
Posts: 3,946
Sometimes these things require additional options to gcc, as with gtk+ and pkg-config. I've never used libusb tho, so I don't know.
__________________

Accuracy and integrity mean nothing if you don't make it past the censors...PYTHAGORAS
MK27 is online now   Reply With Quote
Old 12-02-2008, 08:27 PM   #3
Registered User
 
Join Date: Dec 2008
Posts: 2
Yep, I resolved it of course almost after my post.

Here is the solution w/ screenshots:

http://ubuntuforums.org/showthread.php?p=6297589

Thank you to anyone who spent time looking and thinking it out on my behalf.
cbee is offline   Reply With Quote
Reply

Tags
eclipse, error, libusb, ubuntu

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Header File Headache Bladactania C Programming 12 02-11-2009 06:54 AM
API Thread HEADACHE WaterNut Windows Programming 11 01-16-2007 10:10 AM
I/O headache Strait C++ Programming 5 02-04-2005 12:20 PM
My headache Morgan C Programming 7 12-03-2002 03:33 AM
Linked List headache Unregistered C++ Programming 0 09-23-2001 06:42 PM


All times are GMT -6. The time now is 10:47 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22