无法构建使用Google测试的测试项目

时间:2013-05-11 12:59:13

标签: c++ visual-studio-2010 linker-errors googletest

我构建了谷歌测试项目。

我在General -> Addition Include Directories.中添加了包含目录 我将库目录添加到Linker -> Additional Library directories
我将gtest_maind.lib和gtestd.lib添加到Linker -> Input -> Additional Dependencies

我按照另一个链中的说明更改了Code Generation -> Runtime Library to Multi-threaded Debug (/MTd)

注意:我使用的是Visual Studio 2010

尽管做了上述所有操作,我仍然会收到以下链接错误

Error   1   error LNK2019: unresolved external symbol "public: __thiscall 
Utility::~Utility(void)" (??1Utility@@QAE@XZ) referenced in function "private: virtual
void __thiscall UtiltyTest_test1_Test::TestBody(void)" (?
TestBody@UtiltyTest_test1_Test@@EAEXXZ) C:\Users\<username>\Documents\Visual Studio 
2010\Projects\Calc\CalTest\UtilityTest.obj

我在这里遗漏了什么。有人可以帮我解决这个错误。

1 个答案:

答案 0 :(得分:0)

您是否尝试测试任何.c文件? 因为如果你是你应该试试这个:

#ifdef __cplusplus 
  extern "C" {
#endif
    void cFunctionCalledFromCppFile();
#ifdef __cplusplus 
  }
#endif