Makefile无法编译文件

时间:2013-04-02 20:40:53

标签: c++ netbeans makefile

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文件位于同一目录中,并且与其他成功编译的文件位于同一目录中。任何人都知道什么是错的?

1 个答案:

答案 0 :(得分:0)

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