cppunit 链接错误

发布于 2024-07-13 07:59:11 字数 1175 浏览 7 评论 0原文

当针对 cppunit 编译我的测试套件时,我收到以下链接错误:

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

When compiling my test suite againts cppunit, I get the following linking error:

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

I don't understand this problem as the provided examples link fine.

I am using the macros to register my test:

 CPPUNIT_TEST_SUITE_REGISTRATION
 CPPUNIT_TEST_SUITE
 etc

My test class is derived from
CPPUNIT_NS::TestFixture

and here is the 'main' code:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2024-07-20 07:59:11

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

testrunneru.lib cppunit.lib

您还需要通过向 Linker -> 添加适当的目录名称来确保链接器可以找到该库。 一般-> 其他图书馆目录。

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

如果您可以发布一个非常短但完整的源文件来重现该问题,这也可能会有所帮助。 我想你只是错过了这里的 include 语句?

Are you certain that you have added the appropriate libraries to the Linker -> Input -> Additional Dependencies text box for your project? I believe it should be (for the Release / Unicode version):

testrunneru.lib cppunit.lib

You also need to be sure the linker can find the library by adding the appropriate directory name to Linker -> General -> Additional Library Directories.

A real stretch, but it happened to me once, was I needed to rebuild cppunit. I think my compiler was upgraded or patched.

It might also be helpful if you could post a very short, but complete, source file that reproduces the problem. I think you are only missing the include statements here?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文