我有以下目录:
从 lab01 运行 make
时出现以下错误。
没有规则可以创建“student/Student.class”所需的目标“student/Student.java”。停止。
Human.class 文件已创建,但随后出现错误。
这是我的 makefile:
make: Human.class student/Student.class teacher/Teacher.class Lab01.class
Lab01.class: Lab01.java
javac Lab01.java
teacher/Teacher.class: teacher/Teacher.java
javac teacher/Teacher.java
student/Student.class: student/Student.java
javac student/Student.java
Human.class: Human.java
javac Human.java
clean:
del Lab01.class
del teacher/Teacher.class
del student/Student.class
del Human.class
我以前从未使用过 makefile,所以我不确定是什么导致了错误。有任何想法吗?我正在使用 mac os x,如果这很重要的话。
谢谢。
最佳答案
您正在从 lab001
目录运行该命令。
该位置的路径 student/Student.java
无效。
您需要将 makefile 移动到顶级目录(并将 lab001
添加到 Human.java
和 Human.class
条目)或使用 ../student/Student.java
和 ../student/Student.class
。
还可以做很多其他事情来改进这个 makefile,但这些是问题的根源。
关于java - Mac 操作系统中的 Makefile "No rule to make target"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24835281/