简体   繁体   English

Makefile依赖表

[英]Makefile dependency chart

I have this file: 我有这个文件:

main.c
A.h
A.c
B.h
B.c
X.h

and in main.c I include A and in Ah I include B and in Bh I include Xh How could I write makefile for this? 在main.c中,我包括A,在Ah中,我包括B,在Bh中,包括Xh我该如何编写makefile? please tell me about dependency diagram of this example 请告诉我这个例子的依赖图

Try this: 尝试这个:

main: main.o A.o B.o
    gcc -o main main.o A.o B.o

%.o: %.c
    gcc -c $<

While compiling the .c files you don't have to worry about dependencies yet, only when linking the executable. 编译.c文件时,您不必担心依赖项,仅需链接可执行文件即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM