user4075334
user4075334

Reputation:

Makefile not getting updated

I have following files-

maze: maze.c
    gcc -o maze createMaze.c findcheese_iter.c maze.c -I.

Even after making changes to createMaze.c when I try running make command in the terminal,it says make: 'maze' is up to date. As a result I am not getting the correct answer.When I run the same code by this way it runs-

gcc createMaze.c maze.c  findcheese_iter.c -o exe

Upvotes: 0

Views: 2064

Answers (2)

Morten Jensen
Morten Jensen

Reputation: 5936

As far as I can tell, your problem is that you have set the dependencies for maze to be only maze.c and when you update createMaze.c you are not updating any of the dependencies.

You should add all the files the output-binary actually depends on, to the depend list.

E.g.:

maze: createMaze.c findcheese_iter.c maze.c
    gcc -o maze createMaze.c findcheese_iter.c maze.c -I.

Upvotes: 0

seeppp
seeppp

Reputation: 322

change your makefile to the following:

maze: maze.c createMaze.c findcheese_iter.c
    gcc -o maze createMaze.c findcheese_iter.c maze.c -I.

make will just compile, when the targets right behind the doublepoint changes...

Upvotes: 1

Related Questions