简体   繁体   中英

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? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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