Include files for libUSB Linux and Windows.

For issues with communication ports, protocols, etc.
AWPStar
Posts: 34
Joined: May 03, 2009 21:47

Re: Include files for libUSB Linux and Windows.

Postby AWPStar » Jul 18, 2016 4:40

Hello, can you help me?
Trying to compile my app with libusb under ubuntu(desktop, x86, 13.07.2016, 4.4.0-31-generic).

1. i have installed libuse by using

Code: Select all

sudo apt-get install libusb-1.0-0-dev

/usr/lib/libusb-1.0.so.0.0.0 linked to /usr/lib/libusb-1.0.so

2. inclusion for linux

Code: Select all

#include "usb.bi"


3. fbc test.bas

Got

Code: Select all

ld.exe: cannot find -lusb


When i trying to do it from C with "libusb.h" i'm getting no errors.
Thank you!
St_W
Posts: 1127
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Include files for libUSB Linux and Windows.

Postby St_W » Jul 18, 2016 11:34

When I look into the package contents of "libusb-1.0-0-dev" I only see a library "libusb-1.0.so" (but not "libusb.so"), so try to link "usb-1.0" instead of "usb" (Parameter "-lusb-1.0" or #inclib "usb-1.0").

Alternatively create a symlink "libusb.so" pointing to "libusb-1.0.so"

Which library do you link when using the C code you mentioned?
AWPStar
Posts: 34
Joined: May 03, 2009 21:47

Re: Include files for libUSB Linux and Windows.

Postby AWPStar » Jul 18, 2016 15:52

St_W wrote:so try to link "usb-1.0" instead of "usb" (Parameter "-lusb-1.0" or #inclib "usb-1.0").

That works! You saved my day. Thank you!
AWPStar
Posts: 34
Joined: May 03, 2009 21:47

Re: Include files for libUSB Linux and Windows.

Postby AWPStar » Jul 18, 2016 21:45

New problem.

Code: Select all

undefined reference to 'usb_init'
St_W
Posts: 1127
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: Include files for libUSB Linux and Windows.

Postby St_W » Jul 18, 2016 22:07

AWPStar wrote:New problem.

Code: Select all

undefined reference to 'usb_init'

Looks like you are still missing some library(libraries) to link. Again, which libraries did you link when compiling the C code you mentioned? Just use the same with FB your FB code.
Alternatively "pkg-config --libs libusb-1.0" may help to find out the needed libraries.

//edit: OR the method name is just wrong.
When looking at http://libusb.sourceforge.net/api-1.0/api.html this seems to be the case. There's only "libusb_init", but no "usb_init".

//edit2: I just looked at the headers in the first post in this thread: they are outdated and do not match the current version of libusb. I guess they were translated for libusb 0.1, which seemed to use a different API.

You can't use those old headers. I'd suggest recreating the headers from scratch as there are so many differences.
AWPStar
Posts: 34
Joined: May 03, 2009 21:47

Re: Include files for libUSB Linux and Windows.

Postby AWPStar » Jul 18, 2016 23:02

Thank you, again!
C command line:

Code: Select all

gcc test.c -o test -lusb-1.0


Well, i think i have to translate C header to .bi. But now i don't have much time, so i will write my app in C. Later i will translate it to .bi and share it.
jdmcbride
Posts: 19
Joined: Aug 06, 2016 16:13

Re: Include files for libUSB Linux and Windows.

Postby jdmcbride » Aug 28, 2016 18:56

Hey you guys!

You have my attention and I've got to ask some questions. Why the bother with libusb? I access usb serial devices using "open" and the associated hardware usb-serial port driver...

I'm just curious what you are researching in case I'm missing out on some fun...
caseih
Posts: 1040
Joined: Feb 26, 2007 5:32

Re: Include files for libUSB Linux and Windows.

Postby caseih » Aug 28, 2016 19:22

You can only "open" USB devices that present a serial interface or some other file-like interface. And many USB devices have drivers that present a high-level interface that you can work with. Otherwise you need to work with the USB device over usb protocol, which is what libusb is all about. The nice thing about libusb is that it lets you have access to the USB device from user space, which means you can create user-space drivers (instead of having signed code running in the kernel) for many things. The OWFS project uses libusb to talk to various iButton or 1wire devices via USB without needing any special drivers installed into the OS.

Return to “Hardware Interfaces / Communication”

Who is online

Users browsing this forum: No registered users and 2 guests