On Wed, 2014-08-13 at 17:45 +0400, Рушан Секаев wrote:
> GNU Make 3.81
> Ubuntu 12.04
> 3.8.0-44-generic
> 
> makefile
> 
> hello: main.c hello.c
>     gcc -o hello main.o hello.o
> main.o: main.c
>     gcc -c -o main.o main.c
> hello.o: hello.c
>     gcc -c -o hello.o hello.c
> 
> if i update 'main.c' and run make hello then 'hello' file is not
> updated. Although the documentation is written on the contrary.

When you say "not update", I assume you mean that "hello" is recompiled
but it still has the old behavior, not the changes you made to
"hello.c".

This is because your rule says to rebuild "hello" whenever any of the .c
files change, but in the command line you link the object files:

    gcc -o hello main.o hello.o

Since your target "hello" doesn't depend on the object files, make
doesn't rebuild them and so it always uses the original object files.

If you want to link with the object files you should have your "hello"
depend on the object files, not the source files:

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



_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make
  • this is bug? Рушан Секаев
    • Re: this is bug? Paul Smith

Reply via email to