tags:

views:

260

answers:

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;
}
+2  A: 

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?

Jeremy
did that, no joy
cbrulak
yeah, I put those libs in the 'ignore libraries' filed in the property setting in VS.
cbrulak