Thread: make incorrectly remaking targets

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    17

    make incorrectly remaking targets

    I have a problem with make, sometimes it remakes targets even when nothing has changed.

    This is the simplest makefile that the problem happens on:

    Code:
    all: birthdays.o
    	gcc birthdays.o -obirthdays
    
    birthdays.o: birthdays.c birthdays.h
    	gcc -c birthdays.c
    For some reason it keeps relinking the program ever time I run make, even though nothing has changed.

    Sometimes it works and says nothing to be done, but most of the time it keeps remaking it.
    Does anyone know what I am doing wrong?

  2. #2
    Registered User wintellect's Avatar
    Join Date
    Mar 2006
    Posts
    24
    try this:
    Code:
    all: birthdays
    
    birthdays: birthdays.o
        gcc -o birthdays birthdays.o
    
    birthdays.o: birthdays.c birthdays.h
        gcc -c birthdays.c

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    17
    it still runs:
    gcc -o birthdays birthdays.o
    I don't get it, it should know that it's up to date shouldn't it?

  4. #4
    wise_ron wise_ron's Avatar
    Join Date
    May 2006
    Posts
    75

    Answer

    This is how i compile & run my programs in linux with no trouble:

    Compile: gcc -o birthdays birthdays.c
    Run: ./birthday

    is easy as that, if not go to google and read more about it.

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    This may sound stupid, but check the dates on your files. I had an issue once whereby one of my source files had a modified time in the future. (Stupid school comps didn't know the right time...) When I took the code home, built it, the executable was always "older" than the source.

    Otherwise, there is a flag you can throw to make to have it spit out oodles of info. (Most of it useless) You can try that, see if you can spot anything out of place. (make -d) on mine.

    Also: ".PHONY : all" - if make thought there was a file named "all", and you're not regenerating it, it /might/ be inclined to rebuild. (Though I'd would have thought that wintellect's changes would have fixed this) (Make has always been a bit of a mystery to me... Especially the linux one - me & it don't get along...)

    Just some ideas - good luck!
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile Problem: None rule to make target
    By chris24300 in forum Linux Programming
    Replies: 25
    Last Post: 06-17-2009, 09:45 AM
  2. Establishing 'make clean' with GNU make
    By Jesdisciple in forum C Programming
    Replies: 9
    Last Post: 04-11-2009, 09:10 AM
  3. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 09:51 PM
  4. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  5. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM