2010-05-18 69 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框架的路径/库。