gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 05:47:35 24 4
gpt4 key购买 nike

我是编写 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 namefor that source file, a colon, and the names of all the includedfiles, including those coming from -include or -imacros command lineoptions.

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 orindirectly, from such a header.


如此有效地你是 只是预处理 因此没有编译,没有链接和由此产生的错误。

关于gcc - 链接器输入文件未使用,因为链接未完成 - gcc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10486698/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com