gpt4 book ai didi

c++ - Libusb undefined reference

转载 作者:IT王子 更新时间:2023-10-29 00:08:10 30 4
gpt4 key购买 nike

我正在尝试在我的操作系统上设置 libusb API。我在 libusb.org 下载了 libusb api。我遵循了标准安装程序:

cd into directory
./configure
make
make check //without errors
make install

然后我启动了 Eclipse C/C++ 并从网上找到的教程中复制了一些代码。但是在尝试构建它时,我得到了以下输出:

main.cpp:(.text+0x19): undefined reference to `libusb_init'
main.cpp:(.text+0x76): undefined reference to `libusb_set_debug'
main.cpp:(.text+0x8a): undefined reference to `libusb_get_device_list'
main.cpp:(.text+0x136): undefined reference to `libusb_free_device_list'
main.cpp:(.text+0x142): undefined reference to `libusb_exit'
/tmp/ccOWJGwe.o: In function `printdev(libusb_device*)':
main.cpp:(.text+0x162): undefined reference to `libusb_get_device_descriptor'
main.cpp:(.text+0x28a): undefined reference to `libusb_get_config_descriptor'
main.cpp:(.text+0x4d4): undefined reference to `libusb_free_config_descriptor'
collect2: ld returned 1 exit status

我在/lib 中有 libusb.so,在/usr/local/include 中有 usb.h,在/usr/local/lib 中有 .so 和 libusb.a 的链接。

代码中的#include 也是正确的。

我知道问题出在链接器中,但我有点无法让它工作:)

我使用的是 Fedora 15 操作系统和 gcc 4.6.0 20110603 (Red Hat 4.6.0-10) 版本编译器。

那么我能做些什么来解决这些 undefined reference 呢?非常感谢您的帮助:)

最佳答案

我确实遇到了同样的问题。但我能够通过向链接器添加“-lusb-1.0”来解决它。

例如:g++ myfile.cpp -lusb-1.0

关于c++ - Libusb undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7050482/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com