我正在使用谷歌测试框架来设置一些单元测试。我的解决方案中有三个项目:
- FN(我的项目)
- FN_test(我的测试)
- gtest(谷歌测试框架)
我将 FN_test 设置为将 FN 和 gtest 作为引用(依赖项),然后我想我已经准备好设置我的测试了(我已经将每个人都设置为 /MTd(不这样做会导致我之前链接错误)) .
特别是,我在 FN 中定义了一个名为 Embark 的类,我想使用 FN_test 进行测试。到目前为止,一切都很好。因此,我使用 googletest 编写了一个名为 EmbarkTest 的类,声明了成员 Embark* 并在构造函数中写入:
EmbarkTest() {
e = new Embark(900,2010);
}
然后,按 F7,我得到以下信息:
1>FN_test.obj : error LNK2019: unresolved external symbol "public: __thiscall Embark::Embark(int,int)" (??0Embark@@QAE@HH@Z) referenced in function "protected: __thiscall EmbarkTest::EmbarkTest(void)" (??0EmbarkTest@@IAE@XZ)
1>D:\Users\lg\Product\code\FN\Debug\FN_test.exe : fatal error LNK1120: 1 unresolved externals
有人知道我做错了什么和/或我能做些什么来解决这个问题吗?
编辑:来自 Embark.h 的相关代码
class Embark
{
public:
//Constructor for initial state
Embark(int _id, int _year);
//Destructor
~Embark();
/* ... */
}