2013-01-21 53 views
0

我有簡單的Qt程序。當運行make它給誤差是1200線長Qt:可執行文件不會重新生成

make: Circular main.o <- QThread dependency dropped. 
In file included from mythread.h:4, 
       from main.cpp:3: 
./QThread:1: error: stray '\127' in program 
./QThread:1: error: stray '\2' in program 
./QThread:1: error: stray '\1' in program 
./QThread:1: error: stray '\1' in program 
In file included from mythread.h:4, 
       from main.cpp:3: 
./QThread:1:8: warning: null character(s) ignored 
./QThread:1: error: stray '\2' in program 
./QThread:1:18: warning: null character(s) ignored 
./QThread:1: error: expected constructor, destructor, or type conversion before '>' token 
./QThread:1:20: warning: null character(s) ignored 
./QThread:1: error: stray '\1' in program 
./QThread:1:22: warning: null character(s) ignored 
./QThread:1: error: stray '\240' in program 
./QThread:1: error: stray '\21' in program 
./QThread:1:28: warning: null character(s) ignored 
./QThread:1: error: stray '@' in program 
./QThread:1:34: warning: null character(s) ignored 
./QThread:1: error: stray '@' in program 
./QThread:1: error: stray '\24' in program 
./QThread:1:43: warning: null character(s) ignored 
./QThread:1:54: warning: null character(s) ignored 
./QThread:1: error: stray '@' in program 
./QThread:1:56: warning: null character(s) ignored 
./QThread:1: error: stray '\8' in program 
./QThread:1:58: warning: null character(s) ignored 
./QThread:1:60: warning: null character(s) ignored 

... 

./QThread:16: error: stray '\255' in program 
./QThread:16: error: stray '\255' in program 
./QThread:16: error: stray '\235' in program 
./QThread:16: error: stray '\156' in program 
./QThread:16: error: stray '\137' in program 
./QThread:16: error: stray '\195' in program 
./QThread:16: error: stray '\199' in program 
./QThread:16: error: stray '\144' in program 
./QThread:16:252: warning: null character(s) ignored 
./QThread:16: error: stray '@' in program 
./QThread:16: error: stray '\139' in program 
./QThread:16: error: stray '\16' in program 
./QThread:16: error: stray '\240' in program 
./QThread:16: error: stray '\255' in program 
./QThread:16: error: stray '\8' in program 
./QThread:16: error: stray '\15' in program 
./QThread:16: error: stray '\149' in program 
./QThread:16: error: stray '\194' in program 
./QThread:16: error: stray '\132' in program 
./QThread:16: error: stray '\210' in program 
./QThread:16: error: stray '\139' in program 
./QThread:16: error: expected declaration before '}' token 
In file included from main.cpp:3: 
mythread.h:1:1: unterminated #ifndef 
make: *** [main.o] Error 1 

QThread是可執行文件。當我刪除它並再次運行make時,它編譯成功。但是,當我做一些更改make給我同樣的錯誤。我正在使用qmake創建Makefile,爲什麼可執行文件不會重新生成?

QThread.pro 
###################################################################### 
# Automatically generated by qmake (2.01a) Mon Jan 21 10:22:12 2013 
###################################################################### 

TEMPLATE = app 
TARGET = 

# Input 
HEADERS += mythread.h 
SOURCES += main.cpp mythread.cpp 
+0

在我看來,你的編輯器以解析器不支持的模式保存文件。檢查保存選項。 – lapk

+1

你可以發佈.pro文件的內容嗎?它看起來可能是編譯器試圖編譯.o文件,就好像它是C++源代碼一樣。 .pro文件應包含程序中的.cpp文件列表,而不是.o文件。另外命名可執行文件QThread可能不明智,因爲這也是Qt類的名稱;也許這是混淆了qmake/make系統中的某些東西。 –

+0

@JeremyFriesner我改變了程序名稱,它的工作原理,謝謝。 – Ashot

回答

2

mythread.h確實#include <QThread>,當你自己的可執行文件被命名爲QThread,這個發現你剛剛建立,而不是Qt的自己的頭可執行文件。

您已經重命名了該程序以迴應Jeremy的評論,並且您已經看到它可以正常工作。這是一個很好的選擇。另一種方法是確保包含<QThread>而不是"QThread"(如果您還沒有這樣做),並確保您的編譯器標記已設置爲在Qt的頭文件目錄之前不搜索當前目錄。