LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-20-2010, 02:59 AM   #1
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Rep: Reputation: 0
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.

Last edited by aanand0; 11-20-2010 at 03:15 AM.
 
Old 11-20-2010, 03:07 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Have you tried this?
Code:
make clean
jdk
 
Old 11-20-2010, 03:20 AM   #3
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
yes. I always do this before compiling any make file.
 
Old 11-20-2010, 04:13 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Tried this too ?
Code:
make distclean
 
Old 11-20-2010, 08:36 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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"!!!
 
Old 11-21-2010, 10:30 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by aanand0 View Post
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...
 
1 members found this post helpful.
Old 11-21-2010, 10:36 AM   #7
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
He says that no object file is being generated!
 
Old 11-22-2010, 12:15 AM   #8
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 11-22-2010, 12:20 AM   #9
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.

Last edited by paulsm4; 11-22-2010 at 12:23 AM.
 
Old 11-22-2010, 01:17 AM   #10
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks very much. Got it.
 
Old 11-22-2010, 03:02 AM   #11
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Even after doing rm -f *.o and make clean, I am facing same issue. Object file is not getting generated.
 
Old 11-22-2010, 03:09 AM   #12
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
It it showing some errors ? Paste here the output in code tags: http://www.linuxquestions.org/questi...do=bbcode#code
 
Old 11-22-2010, 04:14 AM   #13
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
I have got the issue fixed. Thanks for the support and help.
 
Old 11-22-2010, 04:21 AM   #14
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by aanand0 View Post
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.
 
Old 11-22-2010, 11:19 PM   #15
aanand0
LQ Newbie
 
Registered: Nov 2010
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] no output on C programming using gcc compiler. segieif03 Programming 39 06-10-2010 07:28 AM
Compiling gcc without compiler? davuuud Linux - Software 6 02-03-2009 11:16 AM
compiling x64 application from ubuntu x86 using gcc compiler samitpmc Programming 9 07-21-2008 04:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration