LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gcc compiler is not compiling old C Programming files beacuse of timestamp issue (https://www.linuxquestions.org/questions/linux-newbie-8/gcc-compiler-is-not-compiling-old-c-programming-files-beacuse-of-timestamp-issue-845467/)

aanand0 11-20-2010 02:59 AM

gcc compiler is not compiling old C Programming files beacuse of timestamp issue
 
Hi,
I am using makefile to complile all C Programming files. But certain files are not getting compiled and hence its object file is not getting generated. This is happening due to files haven't been modified for a long time. It seems that compiler knows that its object file is there hence no need to complie it actually it is not.

Please suggest how to overcome the issue.

jdkaye 11-20-2010 03:07 AM

Have you tried this?
Code:

make clean
jdk

aanand0 11-20-2010 03:20 AM

yes. I always do this before compiling any make file.

Aquarius_Girl 11-20-2010 04:13 AM

Tried this too ?
Code:

make distclean

MTK358 11-20-2010 08:36 AM

Also, you can try running this in all subdirectories where .o files are:

Code:

rm *.o
Just don't put a space between "*" and ".o"!!!

Tinkster 11-21-2010 10:30 AM

Quote:

Originally Posted by aanand0 (Post 4165153)
Hi,
I am using makefile to complile all C Programming files. But certain files are not getting compiled and hence its object file is not getting generated. This is happening due to files haven't been modified for a long time. It seems that compiler knows that its object file is there hence no need to complie it actually it is not.

Please suggest how to overcome the issue.

How is that an issue? That's the whole point (well, at least
a major part of it) of "make" - you only compile what needs
to be compiled rather than the whole source tree...

Aquarius_Girl 11-21-2010 10:36 AM

He says that no object file is being generated!

aanand0 11-22-2010 12:15 AM

Thanks for the suggestions. Yes, my makefile is compiling only some files. Now I have updated the makefile to the current date and it is working fine. This problem comes sometimes only. But I want to know the reason why it happens if file becomes too old and has no modification in it.

paulsm4 11-22-2010 12:20 AM

Hi -

Just to clarify what's already been said:
Quote:

I am using makefile to complile all C Programming files. But certain files are not getting compiled and hence its object file is not getting generated. This is happening due to files haven't been modified for a long time. It seems that compiler knows that its object file is there hence no need to complie it actually it is not.
Yes. Exactly. That's one of the main BENEFITS of using "make", is that it DOESN'T recompile the world - it only does what's necessary. And, in this case, it looks like "make" believed (probably correctly!) that it didn't NEED to recompile most of your object files. That's a Good Thing :)

Quote:

Did you try "make clean"?
Quote:

Q: But I want to know the reason why it happens
Simple: if your source file is NEWER than the object (or, more precisely, if the "target" is older than its "dependency") then no action is needed.
It's a standard convention to have a "clean" target in any makefile, so you can FORCE recompilation if you wish to.

Quote:

Also, you can try running "rm *.o" in all subdirectories where .o files are
This is what "make clean" typically does.

aanand0 11-22-2010 01:17 AM

Thanks very much. Got it.

aanand0 11-22-2010 03:02 AM

Even after doing rm -f *.o and make clean, I am facing same issue. Object file is not getting generated.

Aquarius_Girl 11-22-2010 03:09 AM

It it showing some errors ? Paste here the output in code tags: http://www.linuxquestions.org/questi...do=bbcode#code

aanand0 11-22-2010 04:14 AM

I have got the issue fixed. Thanks for the support and help.

Aquarius_Girl 11-22-2010 04:21 AM

Quote:

Originally Posted by aanand0 (Post 4166906)
I have got the issue fixed. Thanks for the support and help.

It would be better if you would let others know the solution too.

aanand0 11-22-2010 11:19 PM

Actually some other file was also generating the exe file of same name where my source file is present. Hence it was no getting compiled as it sees an exe file already created. I deleted that exe file and now it was working successfully.

Once again thanks for the help and support you all provided to me. I came to know lot many new things.


All times are GMT -5. The time now is 06:23 PM.