2011-09-19 30 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