简体   繁体   中英

Makefile warning: Warning: File `main.cpp' has modification time 2.1e+04 s in the future

I have a working Makefile , but there is a warning that I couldn't fix.

#Use the g++ compiler
CC = g++

# Compiler flags:
#   -Wall (most warnings enabled)
#   -g (for debugging with gdb)
CFLAGS = -Wall

# Executable name:
TARGET = deque_adt

all: main.o deque_adt.o deque_adt

$(TARGET): main.o deque_adt.o
    $(CC) $(CFLAGS) main.o deque_adt.o -o $(TARGET)

main.o: main.cpp deque_adt.h 
    $(CC) $(CFLAGS) main.cpp -c

deque_adt.o: deque_adt.cpp deque_adt.h
    $(CC)  $(CFLAGS) deque_adt.cpp -c

clean:
    rm *.o *~ $(TARGET)

error:

make: Warning: File `main.cpp' has modification time 2.1e+04 s in the future
g++ -Wall main.cpp -c
g++  -Wall deque_adt.cpp -c
g++ -Wall main.o deque_adt.o -o deque_adt
make: warning:  Clock skew detected.  Your build may be incomplete.

Can someone help me out to figure out the problem? I have tried to switch between the elements but it still gives the same warning.

To expand on Ben Voigt's answer:

find /your/dir -type f -exec touch {} +

will update the timestamp on all files in the directory. You can then make clean && make again.

check your computer time. I had the same problem and the root cause was my computer time was in the past - when I update it, it was work perfectly.

That message is usually an indication that some of your files have modification times later than the current system time.

Chech if your system time is in the past. Example:

$ date

If so You have several ways to fix this. the easier one is to install an ntp server:

apt install ntp

Or

yum install ntp

Or ...

Regarding of your operating system (Ubuntu, Centos, ...etc)

just set your system date:

example

date -s "2 OCT 2006 18:00:00"

I've faced the same issue, did the below approach on Ubuntu 20.04 and it worked for me.

touch main_.cpp
cp main.cpp main_.cpp
rm main.cpp
mv main_.cpp main.cpp

Try to use the following:

rm Makefile
sudo qmake yourproj. //or any command to create the makefile again
make clean
make

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM