2010-05-18 67 views
1

我有靜態庫和使用它的另一個程序。繼承類的鏈接錯誤

在靜態庫中如果我定義頭沒有inheretence它工作正常。

class TcpCommunication 

在另一方面如果我使用inheretence用QT類,

class TcpCommunication:public QTcpServer 

我得到鏈接錯誤,當我編譯使用這種靜態庫的代碼。

>MStoDKAPId.lib(TcpCommunication.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QTcpServer::~QTcpServer(void)" ([email protected]@[email protected]) referenced in function "public: virtual __thiscall TcpCommunication::~TcpCommunication(void)" ([email protected]@[email protected]) 

可能是什麼問題? 謝謝。

回答

3

使用靜態庫也需要鏈接到QT

+0

當然你是對的,我加了QtNetworkd.lib,問題就解決了。 – metdos 2010-05-18 12:17:55

4

您需要添加一個引用到包含QTcpServer既可類的定義庫中的應用。

您的IDE應該有一個選項來指定鏈接選項,其中一個將是庫的名稱,另一個將指定庫的搜索路徑。更新這兩個來添加QT框架的路徑/庫。