cppunit 链接错误
当针对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确定已将适当的库添加到链接器中 -> 输入-> 您的项目的其他依赖项文本框? 我相信它应该是(对于Release / Unicode版本):
您还需要通过向 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):
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?