0

再次编译我的测试套件时,我收到以下链接错误:

error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TextTestRunner::~TextTestRunner(void)" (??1TextTestRunner@CppUnit@@UAE@XZ) referenced in function _wmain

我不明白这个问题,因为提供的示例链接很好。

我正在使用宏来注册我的测试:

 CPPUNIT_TEST_SUITE_REGISTRATION
 CPPUNIT_TEST_SUITE
 etc

我的测试类派生自 CPPUNIT_NS::TestFixture

这是“主要”代码:

int _tmain(int argc, _TCHAR* argv[])
{
     // Get the top level suite from the registry
     CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();

     // Adds the test to the list of test to run
     CPPUNIT_NS::TextUi::TestRunner runner;
     runner.addTest( suite );

     // Change the default outputter to a compiler error format outputter
     runner.setOutputter( new CPPUNIT_NS::CompilerOutputter( &runner.result(),
                                                      CPPUNIT_NS::stdCOut() ) );
     // Run the test.
     bool wasSucessful = runner.run();

     // Return error code 1 if the one of test failed.
    return wasSucessful ? 0 : 1;
}
4

1 回答 1

2

您确定已将适当的库添加到项目的链接器 -> 输入 -> 附加依赖项文本框中吗?我相信它应该是(对于 Release / Unicode 版本):

testrunneru.lib cppunit.lib

您还需要确保链接器可以通过将适当的目录名称添加到 Linker -> General -> Additional Library Directories 来找到该库。

一个真正的延伸,但它曾经发生在我身上,我需要重建 cppunit。我认为我的编译器已升级或修补。

如果您可以发布一个非常简短但完整的源文件来重现该问题,这也可能会有所帮助。我认为您只是在这里缺少包含语句吗?

于 2009-01-29T18:12:51.890 回答