gcc - 链接器输入文件未使用,因为链接未完成 - gcc

标签 gcc linker makefile

我是编写 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/

相关文章:

iphone - 链接器错误 - 类不再存在

c++ - vs2010 上的 Zlib 链接器错误

makefile - GNU 为多个目标制定规则

c++ - Makefile:编译 src 和测试目录时出错

file - 如何 "execute"制作文件

c - 我编码不正确吗?

c++ - gcc 错误消息库

c - ubuntu 中的 C 程序运行时错误。但在 SunOS 中执行良好

c - NASM ORG 指令有 GCC 版本吗?

c++ - 在 Debug模式下使用针对 XP (v141_xp) 的 Visual C++ 2017 链接 ODBCCP32.lib 时出现 LNK1103