用C寫我的第一個應用程序,它似乎無法找到頭文件(我安裝以下自述文件中的說明):編譯器找不到安裝庫頭
#include <stdio.h>
#include <stdlib.h>
#include <ftdi.h>
int main (int argc, char *argv[])
{
int ret;
struct ftdi_context = *ftdi;
struct ftdi_version_info version;
if ((ftdi = ftdi_new()) == 0)
{
fprintf(stderr, "ftdi_new failed\n");
}
else {
fprintf(stderr, "Success\n");
}
return 0;
}
但它發現在這裏:
[email protected] ~/Documents/BitBang $ locate ftdi.h
/home/ollieb/.local/share/Trash/files/libftdi/libftdi/ftdipp/ftdi.hpp
/home/ollieb/.local/share/Trash/files/libftdi/libftdi/src/ftdi.h
/home/ollieb/Applications/libftdi1-1.3/build/doc/html/group__libftdi.html
/home/ollieb/Applications/libftdi1-1.3/build/doc/man/man3/ftdi.h.3
/home/ollieb/Applications/libftdi1-1.3/build/doc/man/man3/ftdi.hpp.3
/home/ollieb/Applications/libftdi1-1.3/ftdipp/ftdi.hpp
/home/ollieb/Applications/libftdi1-1.3/src/ftdi.h
/usr/include/libftdi1/ftdi.h
/usr/include/libftdi1/ftdi.hpp
這是當我嘗試編譯發生了什麼,它說,該文件無法找到(當我運行的代碼庫文件夾的例子,他們運行正常):
[email protected] ~/Documents/BitBang $ make
make bitbang
make[1]: Entering directory '/home/ollieb/Documents/BitBang'
cc -Wall -g bitbang.c -o bitbang
bitbang.c:3:18: fatal error: ftdi.h: No such file or directory
compilation terminated.
<builtin>: recipe for target 'bitbang' failed
make[1]: *** [bitbang] Error 1
make[1]: Leaving directory '/home/ollieb/Documents/BitBang'
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2
有什麼確切的錯誤信息? – rubikonx9
您的'ftdi.h'副本(很多*爲*)位於非標準位置,編譯器僅在某些位置搜索標頭。您需要在編譯器命令中添加路徑,很可能'-I/usr/include/libftdi1'將起作用。 –