Linux编译程序时找不到头文件的解决办法
test.c:9:16: fatal error: xxx.h: No such file or directory
#include<xxx.h>
下面叙述以Ubuntu系统为例。
先查找 xxx.h 所在路径:
$ sudo find / -name xxx.h
/usr/local/include/xxx/xxx.h
然后用-I选项把目录加上编译:
$ gcc test.c -o test -I /usr/local/include/xxx
问题解决。
Linux编译程序时如果找不到头文件会提示如下错误:
test.c:9:16: fatal error: xxx.h: No such file or directory
#include<xxx.h>
下面叙述以Ubuntu系统为例。
先查找 xxx.h 所在路径:
$ sudo find / -name xxx.h
/usr/local/include/xxx/xxx.h
然后用-I选项把目录加上编译:
$ gcc test.c -o test -I /usr/local/include/xxx
问题解决。

本文介绍了在Linux环境下,当编译程序时遇到找不到头文件错误的解决方法。通过使用find命令定位头文件位置,并利用gcc的-I选项指定包含目录,从而成功编译程序。
6041

被折叠的 条评论
为什么被折叠?



