我在Visual中有一个解决方案,它有两个项目,即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.cpp中有一个Unit_Test文件,
#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:\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)我不清楚这条消息是什么意思,以及如何解决这个错误。
发布于 2012-07-11 09:53:28
这是通常的检查清单,你的问题之一是:
declspec(dllexport)导出类,也不是在使用declspec(dllimport)调用项目中导入它们。.lib。https://stackoverflow.com/questions/11429971
复制相似问题