我是编写 makefile 的初学者。我有一个类似这样的 makefile:
PATH1 = /ref
CC=gcc
LINK = gcc
INCLUDES = .
INCLUDES += -I/PATH1/inc \
-I/$(PATH1)/abc/inc/ \
-I/$(PATH1)/def/inc/
all: src_file
run: src_file
src_file:
$(CC) $(INCLUDES) -MM /ref/abcd.c -o $@
clean:
rm -f *.o src_file
如果我执行 make,则会收到错误:
linker input file unused because linking not done.
我在 stackoverflow 上读了一些类似的帖子,但找不到解决方案。有人可以告诉我我的 makefile 有什么问题吗?提前致谢。
最佳答案
罪魁祸首是预处理器选项-MM
。来自 gcc pre-processor options ,
-M
Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.
Passing -M to the driver implies -E, and suppresses warnings with an implicit -w.
-MM
Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.
因此,您实际上只是预处理,因此没有编译,没有链接以及由此产生的错误。
关于gcc - 链接器输入文件未使用,因为链接未完成 - gcc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10486698/