[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: this is bug?
From: |
Paul Smith |
Subject: |
Re: this is bug? |
Date: |
Wed, 13 Aug 2014 09:54:53 -0400 |
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
- this is bug?, Рушан Секаев, 2014/08/13
- Re: this is bug?,
Paul Smith <=