无法编译文件

Makefile unable to compile file

本文关键字:文件 编译      更新时间:2023-10-16

Netbeans 7.3gcc 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文件在同一个目录下,并且与其他成功编译的文件在同一个目录下。有人知道是怎么回事吗?

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