为什么 make 告诉我“命令未找到”?
我有以下简单的 makefile:
all:
fat_imgen.exe
其中 fat_imgen.exe
是与 makefile 位于同一目录中的可执行文件。然而,当我尝试运行此命令时,会发生这种情况:
>make
fat_imgen.exe
make: fat_imgen.exe: Command not found
make: *** [all] Error 127
如果我从同一命令提示符运行 fat_imgen
,那么它会按预期启动 - 为什么无法 make find fat_imgen.exe
?
这都是在 Mingw / Windows 下运行的。
I have the following simple makefile:
all:
fat_imgen.exe
Where fat_imgen.exe
is an executable in the same directory as the makefile. When I try and run this however this happens:
>make
fat_imgen.exe
make: fat_imgen.exe: Command not found
make: *** [all] Error 127
If I run fat_imgen
from that same command prompt then it starts as expected - why can't make find fat_imgen.exe
?
This is all running under Mingw / Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当使用简单的命令(例如可执行文件的名称)时,GNU make 将直接启动可执行文件。如果找到可执行文件的目录不在 PATH/path 中,则 make 将失败。
如果您将该目录放入路径中,您的 makefile 应该可以正常工作。
另外,正如 @AlexFarber 的评论中所建议的,通过添加 '
./
' GNU make 将采用更复杂的命令(因为并非所有 shell 都是相同的),并将命令交给配置的壳。这将起作用,因为 shell 是在命令所在的目录中创建的。When using a simple commend like the name of an executable, GNU make will start the executable directly. If the directory where the executable is found is not in the PATH/path, make will fail.
If you put the directory in the path, your makefile should work normally.
Also, as suggested in a comment by @AlexFarber, by adding '
./
' GNU make will assume a more complex command (since not all shells are created equal), and hand the command over to the configured shell. That will work, since the shell is created in the directory where the command is then found.