【问题标题】:Makefile unable to compile fileMakefile 无法编译文件
【发布时间】:2013-04-02 20:40:52
【问题描述】:

Netbeans 7.3 gcc 4.5.3

我查看了这个问题的一些答案,但没有看到我的具体情况。

Netbeans 生成的 makefile 似乎是正确的。 Netbeans 终端窗口中给出的输出给出了 No rule to make target ReadList.cpp ,这似乎是错误的。我不知道发生了什么。

输出窗口显示:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/home/skidmarks/Projects/SLIP/slip'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x-Windows/slip.exe
make[2]: Entering directory `/c/home/skidmarks/Projects/SLIP/slip'
make[2]: *** No rule to make target `ReadList.cpp', needed by `build/Debug/Cygwin_4.x-Windows/ReadList.o'.  Stop.
make[2]: Leaving directory `/c/home/skidmarks/Projects/SLIP/slip'
nbproject/Makefile-Debug.mk:94: recipe for target `.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/home/skidmarks/Projects/SLIP/slip'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 375ms)

使用的makefile显示:

${OBJECTDIR}/SlipReadList.o: SlipReadList.cpp 
    ${MKDIR} -p ${OBJECTDIR}
    ${RM} $@.d
    $(COMPILE.cc) -g -w -MMD -MP -MF $@.d -o ${OBJECTDIR}/SlipReadList.o SlipReadList.cpp

makefile 看起来正确并且适用于其他文件。我已经验证了 .cpp 和 .h 文件在同一个目录中,并且与其他成功编译的文件在同一个目录中。有谁知道出了什么问题?

【问题讨论】:

  • 嗯,错误说丢失的文件是 ReadList.cpp 而不是 SlipReadList.cpp
  • 这有帮助。我没有 ReadList.cpp(但我认为你已经解决了我的问题),签名并感谢。

标签: c++ netbeans makefile


【解决方案1】:
make[2]: *** No rule to make target `ReadList.cpp', needed by `build/Debug/Cygwin

现在看看你的 make 文件:

${OBJECTDIR}/SlipReadList.o: SlipReadList.cpp 

您最初有 readlist.cpp,但 makefile 需要 SlipReadList.cpp。因此,编译器不知道如何处理 readlist.cpp。一个简单的解决方法是将文件的命名更改为 SlipReadList.cpp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-16
    • 1970-01-01
    相关资源
    最近更新 更多