LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 03: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 04:15 AM.
 
Old 11-20-2010, 04:07 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,464

Rep: Reputation: Disabled
Have you tried this?
Code:
make clean
jdk
 
Old 11-20-2010, 04: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, 05:13 AM   #4
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

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

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
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, 11:30 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 11:36 AM   #7
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
He says that no object file is being generated!
 
Old 11-22-2010, 01: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, 01: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 01:23 AM.
 
Old 11-22-2010, 02: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, 04: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, 04:09 AM   #12
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
It it showing some errors ? Paste here the output in code tags: http://www.linuxquestions.org/questi...do=bbcode#code
 
Old 11-22-2010, 05: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, 05:21 AM   #14
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
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-23-2010, 12:19 AM   #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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:28 AM
Compiling gcc without compiler? davuuud Linux - Software 6 02-03-2009 12:16 PM
compiling x64 application from ubuntu x86 using gcc compiler samitpmc Programming 9 07-21-2008 05:53 AM


All times are GMT -5. The time now is 06:46 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration