gcc make problems

I'm trying to compile a program with gcc (under linux) as part of a large project, and even though I have only changed one of the files named in the Makefile, when I type make, the system insists on compiling everything in the Makefile. This takes all of 20 minutes, and is becoming something of a hassle. The strange thing is, it worked normally a little while ago. Could it have anything to do with the permissions on this multi-user system?

Comments

  • If you change a source file (.c, .cc, .cxx, .cpp) then it shouldn't recompile everything. If you change a header (.h, .hh, .hxx, hpp) then it should recompile every source file that includes that header or includes a header than includes that header, and so on, unless you specifically work around it (the easiest way is to 'touch' the object file for that source file). Are the Makefile's dependencies written by hand, or are they generated dynamically? In the latter case, you might want to check the dependencies for the files. Maybe one header that's included almost everywhere is including a header it shouldn't and that changes often. Or maybe you're simple changing headers that are included everywhere.
  • Thanks for the reply. The one file that I'm changing is a .c file that includes a .h file that includes... These includes files are used by the other programs, but are not modified (that I am aware of). The makefile is rather large and complicated, and one thing it does that surprised me is that it deletes the .o files when it's done. I thought that might be causing the recompilation, but it worked that way at first, with the same Makefile and .c file as is failing now. It compiled the whole thing the first time through (>20 min.) and then subsequently it compiled only my program as it changed (~1 sec). But now, even if I change nothing, and just run make twice in a row, it compiles everything. The changes that I made were all in the single .c file, but this is a multiuser system, and I think some of the permissions were changed. Could this touch files?


    : If you change a source file (.c, .cc, .cxx, .cpp) then it shouldn't recompile everything. If you change a header (.h, .hh, .hxx, hpp) then it should recompile every source file that includes that header or includes a header than includes that header, and so on, unless you specifically work around it (the easiest way is to 'touch' the object file for that source file). Are the Makefile's dependencies written by hand, or are they generated dynamically? In the latter case, you might want to check the dependencies for the files. Maybe one header that's included almost everywhere is including a header it shouldn't and that changes often. Or maybe you're simple changing headers that are included everywhere.
    :

  • : The one file that I'm changing is a .c file that includes a .h file that includes...
    If you're only changing a source file (.c) then there's no reason for it to recompile anything except that file (and maybe repackage anything it's used in, but that takes almost no time).

    : The makefile is rather large and complicated, and one thing it does that surprised
    : me is that it deletes the .o files when it's done.
    That's a little odd, you might want to comment out that part of the makefile and see if the behaviour ceases.

    : The changes that I made were all in the single .c file, but this is a multiuser system,
    : and I think some of the permissions were changed. Could this touch files?
    I just did a test, and changing permissions doesn't appear to modify the dates associated with a file.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories