13

My problem is whenever I try to compile using Makefile I get the following :

make: Warning: File `Board.c' has modification time 1.3e+03 s in the future
gcc -Wall -c -Wvla -lm Board.c -o Board.o
gcc -Wall -c -Wvla -lm PlayBoard.c -o PlayBoard.o
gcc -lm ErrorHandle.o Board.o PlayBoard.o -g -o PlayBoard
make: warning:  Clock skew detected.  Your build may be incomplete.

My Makefile is :

CC = gcc
FLAGS = -Wall -c -Wvla

PlayBoard: ErrorHandle.o Board.o PlayBoard.o
    $(CC) -lm ErrorHandle.o Board.o PlayBoard.o -g -o $@

PlayBoard.o: PlayBoard.c Board.o
    $(CC) $(FLAGS) -lm PlayBoard.c -o $@

Board.o : ErrorHandle.o Board.c Board.h
    $(CC) $(FLAGS) -lm Board.c -o $@

.PHONY : clean

clean:
    rm -f Board.o PlayBoard.o PlayBoard

all : PlayBoard

Thank you for your help.

alk
  • 69,737
  • 10
  • 105
  • 255
Nadin Haddad
  • 337
  • 2
  • 3
  • 9
  • 3
    Check the modification time of `Board.c`, it appears that you may have copied this from another source when in the time of creation is ahead of your machin. One solution could be run `touch Board.c` to set the modification time to current time – another.anon.coward Dec 06 '12 at 14:27
  • 1
    are the sources stored on a network location perhaps? – stijn Dec 06 '12 at 14:31
  • This isn't related to C in any way. This is a warning issued by `make`. – alk Jan 31 '17 at 08:37
  • @alk: I can't see any tacit evidence that would warrant this question to be protected. There aren't a lot of answers from low-rep members and there doesn't seem to be any immediate danger of this question being suddenly very popular and getting a lot of attention, either. – Makoto Jan 31 '17 at 08:41

3 Answers3

39

A possible solution is to touch every file in the source tree in order to update time-stamps:

Go to the root of the sub-tree an do:

find . -exec touch {} \; 

Then make clean and retry compilation.

ani627
  • 5,578
  • 8
  • 39
  • 45
sblob
  • 399
  • 3
  • 2
  • 1
    Works every time. Thank you! – steadweb Jun 01 '16 at 16:27
  • 2
    Doing so let's you then always and ever compile all an everything, not just only the source files which had been touched due to code changes. At least for a large code base this probably is not what you want,. – alk May 11 '17 at 05:01
27

As denoted in a comment by stijn the message "Clock skew detected" is most commonly given if compiling sources located on an NFS mount and the NFS server's clock runs ahead the client's clock doing the compilation.

alk
  • 69,737
  • 10
  • 105
  • 255
  • Is there a solution to this? My source files are on an nfs server that appears to be slightly ahead. My dev machine and the nfs server are VM's on seperate domains so I may never get clocks exact – TSG Feb 28 '15 at 01:04
  • @Telium : You might want to run an N(erwork)T(ime)P(rotocol) client on both machines on a regular base? – alk Aug 04 '15 at 06:51
3

I saw this in Eclipse a couple of times as well when doing some work on one of the University computers here. My data drive was a network drive and the clock difference between the network drive and the local machine was off.

Switching my workspace to a location on the local machine (C drive) fixed the problem

medge
  • 598
  • 5
  • 16