[英]make/cc not finding header file even though its directory is present in PATH variable
I am trying to run Allegro on my mac but I keep getting 我试图在Mac上运行Allegro,但我不断
main.cpp:1:10: fatal error:'allegro5/allegro.h' file not found
main.cpp:1:10:致命错误:'allegro5 / allegro.h'文件未找到
error. 错误。
I have installed allegro successfully and I can find the header files in /usr/local/include/allegro5 . 我已经成功安装了allegro,并且可以在/ usr / local / include / allegro5中找到头文件。 I added a path to my environment variable and when I do echo $PATH I can see /usr/local/include.
我在环境变量中添加了一个路径,当我回显$ PATH时,可以看到/ usr / local / include。 In the sample program I am trying to run the include is like this -
在示例程序中,我试图运行include像这样-
#include <allegro5/allegro.h>
and I run- 然后我跑
make main
I can see the header files I have included, why isn't mac able to find the files present in that path? 我可以看到包含的头文件,为什么Mac无法找到该路径中存在的文件?
As @PaulR mentioned, PATH
is where the shell looks for commands, not for where the compiler looks for includes. 如@PaulR所述,
PATH
是外壳程序在其中查找命令的位置,而不是编译器在其中查找包含的位置。 You could also add the -I/usr/local/include
option to your command line as a way to resolve it. 您也可以在命令行中添加
-I/usr/local/include
选项,以解决该问题。
You could check C_INCLUDE_PATH
or CPLUS_INCLUDE_PATH
or INCLUDE_PATH
(not sure which it's looking for). 您可以检查
C_INCLUDE_PATH
或CPLUS_INCLUDE_PATH
或INCLUDE_PATH
(不确定要查找的内容)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.