繁体   English   中英

Makefile 警告:警告:文件 `main.cpp' 在未来有 2.1e+04 s 的修改时间

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

我有一个工作Makefile ,但有一个我无法修复的警告。

#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)

错误:

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.

有人可以帮我解决问题吗? 我试图在元素之间切换,但它仍然给出相同的警告。

要扩展 Ben Voigt 的答案:

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

将更新目录中所有文件的时间戳。 然后你可以再次make clean && make

检查您的计算机时间。 我遇到了同样的问题,根本原因是我的电脑时间已经过去了——当我更新它时,它工作得很好。

该消息通常表明您的某些文件的修改时间晚于当前系统时间。

检查您的系统时间是否在过去。 例子:

$日期

如果是这样,您有几种方法可以解决此问题。 更简单的是安装 ntp 服务器:

apt安装ntp

或者

百胜安装ntp

或者 ...

关于您的操作系统(Ubuntu,Centos,...等)

只需设置您的系统日期:

例子

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

我遇到了同样的问题,在Ubuntu 20.04上做了以下方法,它对我有用。

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

尝试使用以下内容:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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