链接器输入文件未使用,因为未完成链接-gcc [英] linker input file unused because linking not done - gcc
问题描述
我是编写Makefile的初学者.我有一个类似这样的makefile:
I am a beginner in writing makefiles. I have a makefile something like this:
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,我会得到错误:
If I do a make, I get the error:
linker input file unused because linking not done.
我在stackoverflow中读了一些类似的帖子,但找不到解决方案.有人可以让我知道我的makefile怎么了吗?预先感谢.
I read some similar posts in stackoverflow but couldn't get a solution. Could anybody please let me know what's wrong with my makefile? Thanks in advance.
推荐答案
罪魁祸首是预处理程序选项 -MM
.来自 gcc预处理器选项,
The culprit is the preprocessor option -MM
. From gcc pre-processor options,
-M
而不是输出预处理结果,而是输出一条适合于描述主要源文件依赖关系的规则.预处理器输出一个包含目标文件名的生成规则对于该源文件,冒号以及所有包含的名称文件,包括来自-include或-imacros命令行的文件选项.
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.
将-M传递给驱动程序意味着-E,并使用隐含的-w禁止显示警告.
-MM
类似于-M,但不提及直接在系统头目录中找到的头文件,也不提及其中包含的头文件从这样的标题间接获取.
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.
因此,您实际上只是进行预处理,因此无需编译,没有链接以及由此产生的错误.
So effectively you are just preprocessing and hence no compilation and no linking and the resultant error.
这篇关于链接器输入文件未使用,因为未完成链接-gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!