簡體   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