C++ 无法解析错误LNK2019:未解析的外部符号

C++ 无法解析错误LNK2019:未解析的外部符号,c++,visual-studio-2008,lnk2019,C++,Visual Studio 2008,Lnk2019,我在visualstudio中有一个解决方案,它有两个项目,即PAL_测试和Unit_测试。 我有一门PAL_测试课,CPALResponse.h #include "CFW_Stl.h" class CPALResponse { public: void SetCommandSucceeded(bool bCommandSucceeded = false); bool GetCommandSucceeded(); void SetCommandType(int n

我在visualstudio中有一个解决方案,它有两个项目,即PAL_测试和Unit_测试。 我有一门PAL_测试课,CPALResponse.h

#include "CFW_Stl.h"

class CPALResponse
{
  public:
    void SetCommandSucceeded(bool bCommandSucceeded = false);
    bool GetCommandSucceeded();
    void SetCommandType(int nCommandType);
    int GetCommandType();

  private:
    bool m_bCommadSucceeded;
    int m_nCommandType;
};
PAL_TEST CPALResponse.cpp中的另一个文件

#include "stdafx.h"
#include "CFW_CPALResponse.h"

void CPALResponse::SetCommandSucceeded(bool bCommandSucceeded)
{
    m_bCommadSucceeded = bCommandSucceeded;
}
bool CPALResponse::GetCommandSucceeded()
{
    return m_bCommadSucceeded;
}
void CPALResponse::SetCommandType(int nCommandType)
{
    m_nCommandType = nCommandType;
}
int CPALResponse::GetCommandType()
{
    return m_nCommandType;
}
单元测试中有一个文件Unit_Test.cpp

#include "stdafx.h"
#include "../PAL_TEST/CFW_CPALResponse.h"

int _tmain(int argc, _TCHAR* argv[])
{
    CPALResponse a;
    a.SetCommandSucceeded(true);
    return 0;
}
当我构建单元测试项目时,它向我展示了

1>------ Build started: Project: Unit_Test, Configuration: Debug Win32 ------
1>Linking...
1>Unit_Test.obj : error LNK2019: unresolved external symbol "public: void __thiscall CPALResponse::SetCommandSucceeded(bool)" (?SetCommandSucceeded@CPALResponse@@QAEX_N@Z) referenced in function _wmain
1>C:\Users\anubhav.a\Documents\Visual Studio 2008\Projects\PAL_TEST\Debug\Unit_Test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\anubhav.a\Documents\Visual Studio 2008\Projects\PAL_TEST\Unit_Test\Debug\BuildLog.htm"
1>Unit_Test - 2 error(s), 0 warning(s)

我不清楚该消息的含义以及如何解决错误

这是常见的检查表,您的问题是其中之一:

您没有使用declspecdllexport导出类,也没有使用declspecdllimport在调用项目中导入它们

确保使用实现编译文件

确保使用类链接的项目与第一个项目生成的.lib相对应


抱歉,我是使用visual studio或制作windows库的新手。如果你能再多解释一下,那会很有帮助的detail@AnubhavAgarwal谷歌搜索这些术语中的任何一个都会给你带来更多帮助。每件事都应该详细解释。这三个文件在哪里?