Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old December 2nd, 2008   #1
affordablemagic
First Cup of Ubuntu
 
Join Date: Nov 2008
Beans: 2
Arrow usb.h missing usb_init

Hi

I'm attempting to use eclipse on Hardy to brush up (OK, I'm learning from scratch) on C development. The interest is really in robotics (the arduino platform) and while setting the environment I noticed something odd.

One of the tests I am trying to run is accessing images from my USB webcam. I have libusb-dev and libusb-0.1-4.

I am also using CDT for C development.

When I include usb.h and then try and compile with even usb_init(); in my code eclipse complains that "undefined reference to `usb_init'". I can see usb.h in the include folder.

Here's the code (it is something from online)

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;
}
Should I get a source from libusb and compile myself? Is there a reason libusb-dev etc., doesn't work here.

I googled for an answer but nothing seems to strike this problem. Any help appreciated!

Last edited by affordablemagic; December 2nd, 2008 at 09:20 PM.. Reason: Shorter example.
affordablemagic is offline   Reply With Quote
Old December 2nd, 2008   #2
affordablemagic
First Cup of Ubuntu
 
Join Date: Nov 2008
Beans: 2
Smile Re: usb.h missing usb_init

Hi

I resolved the issue. Here it is in case someone comes across it themselves for libusb or indeed another library.

In `step 1` image attached you can see my simple usb project in eclipse. On the project folder i.e., `usb` in my example, right click, and select `Properties`.

You'll get a pop-up box. This is `step 2` image. Select the `C/C++ Build` option on the left, then under `GCC C Linker` drop-down list select `Libraries`. You can see on the image, highlighted w/ an orange background, the word `usb`. I added this Library by clicking the `add` icon and entering the text `usb` from the `Libraries (-l)` pane.
Attached Images
File Type: png step1.png (99.0 KB, 75 views)
File Type: png step2.png (138.3 KB, 70 views)
affordablemagic is offline   Reply With Quote
Old December 9th, 2008   #3
ifknot
First Cup of Ubuntu
 
ifknot's Avatar
 
Join Date: Apr 2008
Beans: 3
Lightbulb Re: usb.h missing usb_init

thank you for that saved me hours of frustration!
__________________
Its origin and purpose still a total mystery.
ifknot is offline   Reply With Quote
Old December 22nd, 2008   #4
bkuhns
Spilled the Beans
 
Join Date: Jun 2006
Beans: 14
Re: usb.h missing usb_init

Wow, yeah... thanks a ton! I had a feeling I had to do something like that, but had no idea where to do it. Saved me a ton of time figuring it out, thanks again!
bkuhns is offline   Reply With Quote

Bookmarks

Tags
cdt, eclipse, error, libusb, ubuntu

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:04 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry