我在 Qt
1 中有两个模块。SapPackets:lib
2.SapApplication:
两个模块的 app pro 文件
SapPackets.pro 有 Qt -= gui
SapApplication.pro 有 Qt += core gui xml
目标操作系统是 Windows 7
SapPacket.lib 中有一个类 SapEntity
#ifndef SAPENTITYCLASS_HPP
#define SAPENTITYCLASS_HPP
#include <QString>
namespace Sap
{
namespace Entity
{
class SapEntityClass
{
protected:
unsigned short mush_Id; /* Entity Id */
QString msz_title; /* Entity Title */
public:
SapEntityClass(const unsigned short Id,const QString title);
unsigned short GetId() const;
QString GetTitle() const;
};
}
}
#endif
SapEntity 的实现文件是
#include "SapEntityClass.hpp"
using namespace Sap::Entity;
SapEntityClass::SapEntityClass(const unsigned short Id,const QString title)
:mush_Id(Id),msz_title(title)
{}
inline
unsigned short SapEntityClass::GetId() const
{
return mush_Id;
}
inline
QString SapEntityClass::GetTitle() const
{
return msz_title;
}
SapApplication.pro 具有以下用于添加 SapPackets.lib 的行
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../SapPackets_Build/release/ - lSapPackets
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../SapPackets_Build/debug/ -lSapPackets
else:unix: LIBS += -L$$PWD/../SapPackets_Build/ -lSapPackets
INCLUDEPATH += $$PWD/../SapPackets
DEPENDPATH += $$PWD/../SapPackets
SapApplication 中的主要功能
#include <iostream>
#include "SapEntityClass.hpp"
using namespace Sap::Entity;
int main(int argc, char *argv[])
{
SapEntityClass obj(56,"Sample");
std::cerr<<obj.GetId();
return 0;
}
问题: 我在 Compilationa 上收到以下错误
main.obj:-1: error: LNK2019: unresolved external symbol "public: unsigned short
__thiscall Sap::Entity::SapEntityClass::GetId(void)const " (?
GetId@SapEntityClass@Entity@Sap@@QBEGXZ) referenced in function _main
请帮我解决这个问题......