2011-09-19 90 views
0

我在Ubuntu Linux中使用代码块。我想用libusb库编写程序。我在系统中有这个文件,但IDE中的编译器找不到这个文件。我在这个文件中添加了“构建选项”,这没有帮助。这个问题的解决方案是什么?libusb在IDE中不可见

#include <libusb.h> 

更新:

dpkg -L libusb-dev显示如下:

/. 
/usr 
/usr/bin 
/usr/bin/libusb-config 
/usr/include 
/usr/include/usb.h 
/usr/lib 
/usr/lib/libusb.a 
/usr/lib/libusb.la 
/usr/lib/pkgconfig 
/usr/lib/pkgconfig/libusb.pc 
/usr/share 
/usr/share/doc 
/usr/share/doc/libusb-dev 
/usr/share/doc/libusb-dev/changelog.gz 
/usr/share/doc/libusb-dev/html 
/usr/share/doc/libusb-dev/html/index.html 
/usr/share/doc/libusb-dev/html/preface.html 
/usr/share/doc/libusb-dev/html/intro.html 
/usr/share/doc/libusb-dev/html/intro-overview.html 
/usr/share/doc/libusb-dev/html/intro-support.html 
/usr/share/doc/libusb-dev/html/api.html 
/usr/share/doc/libusb-dev/html/api-device-interfaces.html 
/usr/share/doc/libusb-dev/html/api-timeouts.html 
/usr/share/doc/libusb-dev/html/api-types.html 
/usr/share/doc/libusb-dev/html/api-synchronous.html 
/usr/share/doc/libusb-dev/html/api-return-values.html 
/usr/share/doc/libusb-dev/html/functions.html 
/usr/share/doc/libusb-dev/html/ref.core.html 
/usr/share/doc/libusb-dev/html/function.usbinit.html 
/usr/share/doc/libusb-dev/html/function.usbfindbusses.html 
/usr/share/doc/libusb-dev/html/function.usbfinddevices.html 
/usr/share/doc/libusb-dev/html/function.usbgetbusses.html 
/usr/share/doc/libusb-dev/html/ref.deviceops.html 
/usr/share/doc/libusb-dev/html/function.usbopen.html 
/usr/share/doc/libusb-dev/html/function.usbclose.html 
/usr/share/doc/libusb-dev/html/function.usbsetconfiguration.html 
/usr/share/doc/libusb-dev/html/function.usbsetaltinterface.html 
/usr/share/doc/libusb-dev/html/function.usbresetep.html 
/usr/share/doc/libusb-dev/html/function.usbclearhalt.html 
/usr/share/doc/libusb-dev/html/function.usbreset.html 
/usr/share/doc/libusb-dev/html/function.usbclaiminterface.html 
/usr/share/doc/libusb-dev/html/function.usbreleaseinterface.html 
/usr/share/doc/libusb-dev/html/ref.control.html 
/usr/share/doc/libusb-dev/html/function.usbcontrolmsg.html 
/usr/share/doc/libusb-dev/html/function.usbgetstring.html 
/usr/share/doc/libusb-dev/html/function.usbgetstringsimple.html 
/usr/share/doc/libusb-dev/html/function.usbgetdescriptor.html 
/usr/share/doc/libusb-dev/html/function.usbgetdescriptorbyendpoint.html 
/usr/share/doc/libusb-dev/html/ref.bulk.html 
/usr/share/doc/libusb-dev/html/function.usbbulkwrite.html 
/usr/share/doc/libusb-dev/html/function.usbbulkread.html 
/usr/share/doc/libusb-dev/html/ref.interrupt.html 
/usr/share/doc/libusb-dev/html/function.usbinterruptwrite.html 
/usr/share/doc/libusb-dev/html/function.usbinterruptread.html 
/usr/share/doc/libusb-dev/html/ref.nonportable.html 
/usr/share/doc/libusb-dev/html/function.usbgetdrivernp.html 
/usr/share/doc/libusb-dev/html/function.usbdetachkerneldrivernp.html 
/usr/share/doc/libusb-dev/html/examples.html 
/usr/share/doc/libusb-dev/html/examples-code.html 
/usr/share/doc/libusb-dev/html/examples-tests.html 
/usr/share/doc/libusb-dev/html/examples-other.html 
/usr/share/doc/libusb-dev/copyright 
/usr/share/doc/libusb-dev/changelog.Debian.gz 
/usr/share/doc-base 
/usr/share/doc-base/libusb-dev 
/usr/share/man 
/usr/share/man/man1 
/usr/share/man/man1/libusb-config.1.gz 
/usr/lib/libusb.so 

但是,当我改变#include <libusb.h>#include <usb.h>,并尝试编译这段代码:

#include <stdio.h> 
#include <stdlib.h> 
#include <usb.h> 
int main(){ 
    usb_init(); 
    printf("Hello world!\n"); 
    return 0; 
} 

我得到的以下错误:

undefined reference to 'usb_init' 
+0

由于Borland已经无关的代码块,和Borland C++编译器只存在于Win32,我相信一句话'Borland公司应该从你的问题被丢弃? –

+0

感谢您的回复。我使用gcc 4.4.5,他的thorow“文件或目录未找到”免费翻译成英文。 我在OS libusb-dev包中。 – user902691

+0

检查我更新的答案。我有一种直觉,你正在指定错误的头文件名。 –

回答

1

好像libusb-dev丢失。

或者

执行dpkg -L libusb-dev列出所有的文件libusb-dev包找出什么是适当的包括文件的名称和它的位置。最有可能你最终会改变你包括到:

#include <usb.h> 

此外,它是不够的只是一个头添加到程序 - 你需要证明什么库应与使用在声明的那些符号标题。以下添加到您的编译器选项:

-lusb