错误:LNK2019:Qt中无法解析的外部符号

i

我在Qt
1中有两个模块。SapPackets:lib
2. SapApplication:
两个模块的
SapApplication应用程序文件SapPackets.pro具有
Qt- = gui SapApplication.pro具有Qt + =核心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

请帮助我解决这个问题。

强尼

编辑:为什么您要在实现文件中内联该方法?内联函数及其声明必须具有可见的定义。GCC针对实现文件中的内联方法报告了相同的链接器错误,因此我认为这是您的问题-删除方法定义中的内联方法或将其移至标头。

旧答案:好吧,您只发布了带有Sap :: Entity :: SapEntityClass :: GetId()方法声明的标头。定义在哪里?看来它没有实现,或者至少没有链接到您的应用程序。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误LNK2019:无法解析的外部符号“ public:__thiscall

Visual Studio的LNK2019错误-无法解析的外部符号

问题:“错误LNK2019:无法解析的外部符号”

错误LNK2019:无法解析的外部符号“ public:

错误LNK2019:无法解析的外部符号:: FindWindow()函数

LNK2019:C ++ / CLI中无法解析的外部符号

使用defalt args时在函数_main中引用的错误LNK2019无法解析的外部符号

错误LNK2019:函数main中引用了无法解析的外部符号

Visual Studios C ++代码中的错误。Lab4.obj:错误LNK2019:无法解析的外部符号“布尔__cdecl

错误 LNK2019:未解析的外部符号静态库

如何修复LNK2019无法解析的外部符号

Visual Studio中的wxwidgets应用程序给出错误“ LNK2019无法解析的外部符号”

错误LNK2019:无法解析的外部符号_打开CV程序

错误LNK2019:无法解析的外部符号-功能模板的msvc调试版本

错误LNK2019:将代码放入cpp文件时出现无法解析的外部符号

Google测试:错误LNK2019:Visual Studio 2013无法解析的外部符号

错误LNK2019无法解析的外部符号-类库问题?

如何解决错误LNK2019:无法解析的外部符号-功能?

错误LNK2019:无法解析的外部符号libcurl Visual Studio

LNK2019错误(无法解析的外部符号)将SQLite链接到DLL

错误LNK2019:无法解析的外部符号“ public:void__thiscall Start :: showMenu(void)”

nanodbc 错误 LNK2019:无法解析的外部符号 - 在基本连接上

是什么导致此LNK2019无法解析的外部符号错误?

错误 LNK2019:无法解析的外部符号(libJPEG 编译和链接)

错误LNK2019:使用SendInput()时出现无法解析的外部符号

C ++:错误LNK2019:函数_main中引用的未解析的外部符号

错误LNK2019:函数DriverEntry中引用的未解析的外部符号__CheckForDebuggerJustMyCode

在 VScode 上获取“错误 LNK2019:函数_main 中引用的未解析外部符号”

LNK2019:Visual Studio C ++中无法解决的外部符号错误