无法解决错误LNK2019:未解析的外部符号
Unable to resolve error LNK2019: unresolved external symbol
我在Visual Studio中有一个解决方案,它有两个项目,即PAL_TEST和Unit_TEST
我在PAL_TEST,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中有一个文件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;
}
当我构建Unit_Test项目时,它会向我显示
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:Usersanubhav.aDocumentsVisual Studio 2008ProjectsPAL_TESTDebugUnit_Test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:Usersanubhav.aDocumentsVisual Studio 2008ProjectsPAL_TESTUnit_TestDebugBuildLog.htm"
1>Unit_Test - 2 error(s), 0 warning(s)
我不清楚该消息的含义以及如何解决错误
这是常见的检查表,您的问题是其中之一:
-
您既没有导出具有
declspec(dllexport)
的类,也没有在具有declspec(dllimport)
的调用项目中导入它们。 -
确保使用实现编译文件。
-
确保使用类的项目链接到第一个项目生成的
.lib
。
相关文章:
- C++:Application.cpp中抛出了未解析的外部符号(解决方案在问题的末尾,供未来的读者参考)
- 未解析的外部符号_MsiLocateComponentW@12.
- 在C++中使用 gRPC 时未解析的外部符号
- LibPrivoxy: 未解析的外部符号 __declspec(dllimport) int __stdcall Sta
- 尝试从 XamlApplication 编译 C++/WinRT 空白应用程序时,我收到未解析的外部符号 winrt_make_*
- 我收到错误LNK2001:未解析的外部符号(C++代码)
- 可视抽象类 c++(错误 LNK 2001:未解析的外部符号)
- 如何摆脱C++中未解析的外部符号"private: static char"错误?
- 当 lib 已添加到其他依赖项时,如何在 VS 中调试未解析的外部符号错误
- 仅在少数方法(静态或共享库)中解析的外部符号
- 未解析的外部符号"__declspec(dllimport)与 Spdlog c++ 库
- 函数 _main (OPENGL C++) 中引用的未解析的外部符号 ________
- 错误LNK2019未解析的外部符号"public: __thiscall SLinkList<char>::SLinkList<char>(void)"
- 使用静态 constexpr 成员的未解析外部符号
- 引入参数化构造函数后显示 LNK 2019 未解析外部符号的代码错误
- Dlib LNK2001未解析的外部符号USER_ERROR__consistent_build_configurati
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- 链接器错误:切换到unicode生成给出:未解析的外部符号WinMain
- 类模板上一个特定函数的未解析外部符号
- LNK2001:未解析的外部符号public:static类std::vector