【发布时间】:2015-05-30 17:33:37
【问题描述】:
# Set the flags for the C compiler
CFLAGS= -Wall -pedantic -std=c99
# Build rule for the final executable
ass.exe: assemble.o branch.o dataProcessing.o multiply.o singleDataTransfer.o special.o
$(CC) $ˆ -o $@
# Build rules for the .o files
assemble.o: assemble.c dataProcessing.h multiply.h singleDataTransfer.h special.h branch.h
$(CC) $(CFLAGS) $< -c -o $@
branch.o: branch.c branch.h
$(CC) $(CFLAGS) $< -c -o $@
dataProcessing.o: dataProcessing.c dataProcessing.h
$(CC) $(CFLAGS) $< -c -o $@
multiply.o: multiply.c multiply.h
$(CC) $(CFLAGS) $< -c -o $@
singleDataTransfer.o: singleDataTransfer.c singleDataTransfer.h
$(CC) $(CFLAGS) $< -c -o $@
special.o: special.c special.h
$(CC) $(CFLAGS) $< -c -o $@
# Rule to clean generated files
clean:
rm -f
# Tell make that ‘clean’ is not a real file
.PHONY: clean
这是我拥有的 makefile 文件。但是无法创建最终的可执行文件,尽管可以创建所有其他 .o 文件,并且我可以使用此 makefile 创建的那些 .o 文件在终端中编译可执行文件。 有人可以就如何纠正我的makefile中的错误提供一些建议吗?
这是错误信息:
cc � -o ass.exe
cc: error: �: No such file or directory
cc: fatal error: no input files
compilation terminated.
make: *** [ass.exe] Error 4
【问题讨论】:
-
错误,
ass.exe??!你最好重命名这个可执行文件。 -
你能发布确切的错误信息吗?编辑问题并将其添加到底部。
-
好的!我已经添加了详细的错误消息。这表示该文件不存在。
-
关于可执行文件的规则,您应该使用
LINK.c变量而不是CC,因为它考虑了许多有用的其他选项变量。从make -p,定义为LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)