用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'将起作用。 –