0

我正在尝试构建一个使用 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 消息一直告诉我它没有安装。谁能给我一个进去的方向?任何帮助表示赞赏。

4

1 回答 1

1

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

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

对于 libusb 1.0,include 语句将是

#include <libusb-1.0/libusb.h>

并且链接器选项是

-lusb-1.0
于 2011-11-03T00:16:09.430 回答