D
D
DVoropaev2019-07-14 13:19:39
GNU Make
DVoropaev, 2019-07-14 13:19:39

Why do we need make dependencies?

hello: main.c hello.c
        gcc -o hello main.c hello.c

Why does "hello:" need "main.c" and "hello.c" ?
they are on the team.
It turns out that the duplication of information

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
CityCat4, 2019-07-14
@DVoropaev

So that in the event that main.c OR hello.c has changed by the time make is executed, each of them would be recompiled. If this is not done, there is a risk that the source is newer, and the older object module will be included in the binary.

L
Lynn "Coffee Man", 2019-07-14
@Lynn

Because in the general case, the command and dependencies are not related in any way.
Specifically, here you can avoid duplication using automatic variables
gcc -o [email protected] $^

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question