【问题标题】:cppunit linking errorcppunit 链接错误
【发布时间】:2009-01-29 17:08:14
【问题描述】:

在重新编译我的测试套件时,我收到以下链接错误:

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;
}

【问题讨论】:

    标签: linker cppunit


    【解决方案1】:

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

    testrunneru.lib cppunit.lib

    您还需要确保链接器可以通过将适当的目录名称添加到链接器 -> 常规 -> 附加库目录来找到该库。

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

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

    【讨论】:

    • 是的,我将这些库放在 VS 属性设置中的“忽略库”字段中。
    猜你喜欢
    • 1970-01-01
    • 2012-12-12
    • 2010-11-04
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2012-12-24
    • 2014-02-13
    • 2014-06-23
    相关资源
    最近更新 更多