PaulStoffregen / teensy_loader_cli

Command line Teensy Loader
http://www.pjrc.com/teensy/loader_cli.html
332 stars 152 forks source link

usb.h is not found #30

Closed kamikaze closed 2 years ago

kamikaze commented 7 years ago

Looks like there is a build error with new libusb:

cc -O2 -Wall -s -DUSE_LIBUSB -o teensy_loader_cli teensy_loader_cli.c -lusb
teensy_loader_cli.c:215:17 fatal error: usb.h: No such file or directory

I have libusb-1.0.21 installed on Gentoo

neonsoftware commented 7 years ago

Hi @kamikaze .

to my knowledge teensy_loader_cli used to be based on libusb version 0.1, which has usb.h. It used to be written in the comments in the code but can't remember where and when. Please anyone correct me if I am wrong.

Version 1.0 of libusb, which you have installed, has a new and different API from 0.1. (0.1 and 1.0 are two 'era' of the libusb library, and both are still separately used and packaged, long story )

Anyways one versatile and easy solution that allows you to use both the API of 0.1 and 1.0 (in case you will need it) is to use the package libusb-compat, look for it on your package manager, debian has it, hope gentoo too.

[ fyi what internally that package does is providing 1.0 as it is, and also providing headers and wrapper functions that provide the 0.1 API, where the internal implementation is actually done using 1.0 ]

You could uninstall your libusb-1.0.21 before installing libusb-compat

Hope it works :)

PaulStoffregen commented 7 years ago

Can anyone suggest specific text to document this in the comments in the code? Ideally that text would have the exact package names or info needed for various Linux distros which don't provide this header by default.

neonsoftware commented 7 years ago

I'll attempt to try-out cloning&compilation on the various distributions, clean install, and note down the steps.
By now on Debian,Ubuntu and ArchLinux the package libusb-compat is available in the package manager and gets the compilation done. Next I will check Red-Hat, Fedora, and Gentoo.

I will post updates and info here. Any help or request of distro to try is welcome.

kamikaze commented 7 years ago

why not to use newer libusb?

PaulStoffregen commented 7 years ago

why not to use newer libusb?

Do you want to update the code and test throughly? I know I have much better things to do.

neonsoftware commented 7 years ago

Hi @PaulStoffregen,

commit https://github.com/neonsoftware/teensy_loader_cli/commit/e9683457d99dc21b7fe7617e2da1140c28e9ba3f adds text to document libusb0.1 installation on various linux distros and freebsd. Please let me know if anything can be added or modified. If it is interesting to you then I'll make a pull request

neonsoftware commented 7 years ago

I have tested it against the Linux distros by setting up a CI job that runs on Travis, this is the live badge Build Status. I have added the use of the 'latest' tag where available, so it will always check against the latest distribution release. It is in https://github.com/neonsoftware/teensy_loader_cli/commit/d0a76581d24600656f4c28b5b195b28763b5929c if you are interested, but otherwise I will keep the fork updated and let you know when newer releases break.

Regarding freebsd, I tested by creating a virtual machine with version 10.3-release, if other versions must be checked, then let me know.

PaulStoffregen commented 7 years ago

If it is interesting to you then I'll make a pull request

Yes, please do, for https://github.com/neonsoftware/teensy_loader_cli/commit/e9683457d99dc21b7fe7617e2da1140c28e9ba3f

neonsoftware commented 7 years ago

pull https://github.com/PaulStoffregen/teensy_loader_cli/pull/31

neonsoftware commented 7 years ago

with instructions being in #31 I then guess the issue might be closed

neonsoftware commented 7 years ago

👍 and thanks for all the good work you put in the project