2017-05-12 37 views
1

我有問題鏈接測試項目;這是錯誤:鏈接器錯誤與源內部構建在Qt 5

DataGUI.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl GuiUtilities::TreeModel::TreeModel(class QObject *)" ([email protected]@@[email protected]@@@Z) referenced in function "public: __cdecl GuiUtilities::DataGUI::DataGUI(class QWidget *)" ([email protected]@@[email protected]@@@Z) 

File not found: DataGUI.obj 

The process "C:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2. 
Error while building/deploying project DataGUI (kit: Desktop Qt 5.8.0 MSVC2015_64bit) 
The kit Desktop Qt 5.8.0 MSVC2015_64bit has configuration issues which might be the root cause for this problem. 

目標文件'DataGUI.obj'確實存在。

我做一個徹頭徹尾的源碼編譯的,因此:

./Project/sources 
./Project/*.pro 
./Build/build-Project-.../Debug/DataGUI.obj 

具有完全相同的配置,我已經建立了其他的Qt項目成功。

+0

是否錯誤依然後您「清除」的項目堅持,並重新構建它? – Danyright

+0

@Danyright:是的,我一直得到同樣的錯誤。 – Pietro

+0

好的。然後我會檢查你的代碼。有沒有可能你不能正確鏈接(#include)TreeModel類?你能發佈DataGUI的代碼嗎? – Danyright

回答

1

這個問題本身部分固定,但我留下這個問題作爲參考,以防其他人發生同樣的情況。

這是事件的順序:在調試模式的IDE工作

  • 程序編譯時沒有任何錯誤/警告。
  • 我得到了問題中報告的鏈接器錯誤。
  • 試圖重建整個項目多次,沒有成功。
  • 將IDE設置爲發佈模式。
  • 有許多編譯時錯誤。
  • 將IDE設置回調試模式。
  • 得到了與發佈模式相同的編譯時錯誤。

現在我固定編譯時錯誤...

+1

提示:有時候手動刪除build dir會有所幫助。清潔有時不會成功。 –