linux - libusb 不会安装?

标签 linux usb installation libusb

我正在尝试构建一个使用 libusb 的程序,但出现了很多错误,例如

i2cbrdg.c:84: error: implicit declaration of function ‘usb_init’
i2cbrdg.c:88: error: implicit declaration of function ‘usb_find_busses’
i2cbrdg.c:89: error: implicit declaration of function ‘usb_find_devices’
i2cbrdg.c:90: error: implicit declaration of function ‘usb_get_busses’

所以我正在尝试安装 libusb,但在安装时遇到了麻烦。我已经安装了 libusb-dev,看起来没问题。当我执行 dpkg -L libusb-dev 时,我得到一个目录列表。但是,当我 dpkg -L libusb 时,我得到了

Package `libusb' is not installed.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

我已经完成了 sudo apt-get install libusb-1.0,一切顺利。当我再次尝试这样做时,我收到消息

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libusb-1.0-0' for regex 'libusb-1.0'
Note, selecting 'libusb-1.0-0-dev' for regex 'libusb-1.0'
libusb-1.0-0-dev is already the newest version.
libusb-1.0-0 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我也试过用 yum 安装它,它仍然说它没有安装。我已经下载了包的 tar 并在上面运行 make,这似乎也没有问题(没有明确的错误消息)。我真的不知道接下来要尝试什么。 dpkg 消息一直告诉我它没有安装。谁能给我一个方向进去?感谢您的帮助。

最佳答案

库 libusb 0.1 和 libusb 1.0 非常不同。您现在应该决定要使用哪一个。我推荐 libusb 1.0。我上次检查时,libusb-devlibusb 包安装了 libusb 0.1,而 libusb-1.0-0-dev 包应该安装libusb 1.0,至少在 Ubuntu 中是这样。

安装所需的库后,您需要在 C 文件中#include 头文件并添加正确的链接器选项。

对于 libusb 1.0,include 语句是

#include <libusb-1.0/libusb.h>

链接器选项是

-lusb-1.0

关于linux - libusb 不会安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7988688/

相关文章:

linux - 打印 Cscope 符号链接(symbolic link)的绝对路径

c - 关于 ether_addr_equal 函数的未对齐问题?

delphi - 使用delphi检测USB驱动器/设备

python - 在 python 3 上安装 dpkt

linux - 在 Unix shell 中压缩列之间的空间

c++ - SDL+OpenGL 程序没有出现在 linux 上

python - 使用 PyUSB 从 Tenma 72-7732 万用表读取数据

python - 在 Linux 上使用 python 获取 USB 驱动器唯一 ID 的最简单方法是什么?

package - 从 Nix 存储库外部安装

.net-3.5 - 如何判断是否安装了 .NET 3.5 SP1?