java - Mac 操作系统中的 Makefile "No rule to make target"错误

标签 java makefile

我有以下目录:

enter image description here

从 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.javaHuman.class 条目)或使用 ../student/Student.java../student/Student.class

还可以做很多其他事情来改进这个 makefile,但这些是问题的根源。

关于java - Mac 操作系统中的 Makefile "No rule to make target"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24835281/

相关文章:

java - 如何使用 IntelliJ Idea 15 调试 JSP 文件(断点不起作用)

makefile - dpkg 错误 : contains ununderstood data member

windows - Cygwin,如何为在根目录和任何子目录中找到的所有 makefile 运行 "make"?

java - 调用 JavaPairRDD.max 时 Spark 中的任务不可序列化异常

java - 是否有类似 IF NOT EXISTS 的命令用于插入值?

java - 不同的存储库对象将被注入(inject)以引用

java - 以一个字符串作为输入,如果它完全由 Java 中的字符 A、T、C、G 组成,则返回有效

ubuntu - 设置 make 总是同时做 8 个工作

makefile - 如何替换makefile目标中全局变量的定义?

c - 为什么gnu make命令默认编译同名的c文件