ubuntu在线安装和卸载libusb
- 在线安装命令
-
1.安装命令: Ubuntu 测试 其他linux应该是一样的sudo apt-get install libusb-1.0-0-dev sudo apt-get install libusb-dev2.如果需要卸载sudo apt-get remove libusb-1.0-0-dev sudo apt-get remove libusb-dev
- 编译命令
-
libusb库 1.23 之前(应该是的 1.23之前没有做测试) 例1.gcc -o main main.c -lusb libusb库 1.23 之后 例2.gcc -o main main.c -lusb-1.0
- 问题及测试程序 点击访问
-
#include
#include #include #include #include #include #include static void print_devs(libusb_device **devs) {libusb_device *dev;int i = 0;while ((dev = devs[i++]) != NULL) {struct libusb_device_descriptor desc;int r = libusb_get_device_descriptor(dev, &desc);if (r < 0) {fprintf(stderr, "failed to get device descriptor");return;}printf("%04x:%04x (bus %d, device %d)\n",desc.idVendor, desc.idProduct,libusb_get_bus_number(dev), libusb_get_device_address(dev));} }int main(void) {libusb_device **devs;int r;ssize_t cnt; r = libusb_init(NULL);if (r < 0)return r;cnt = libusb_get_device_list(NULL, &devs);if (cnt < 0)return (int) cnt;print_devs(devs);libusb_free_device_list(devs, 1);libusb_exit(NULL);return 0;}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!