Domanda

Quando compilo la mia suite di test contro cppunit, ottengo il seguente errore di collegamento:

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

Non capisco questo problema poiché il collegamento degli esempi forniti va bene.

Sto usando le macro per registrare il mio test:

 CPPUNIT_TEST_SUITE_REGISTRATION
 CPPUNIT_TEST_SUITE
 etc

La mia classe di test è derivata da      CPPUNIT_NS :: TestFixture

ed ecco il codice 'principale':

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;
}
È stato utile?

Soluzione

Sei sicuro di aver aggiunto le librerie appropriate al Linker - > Input - & Gt; Casella di testo Dipendenze aggiuntive per il tuo progetto? Credo che dovrebbe essere (per la versione Release / Unicode):

  

testrunneru.lib cppunit.lib

Devi anche essere sicuro che il linker possa trovare la libreria aggiungendo il nome di directory appropriato a Linker - > Generale - & Gt; Directory librerie aggiuntive.

Un vero tratto, ma una volta mi è successo, è stato necessario ricostruire cppunit. Penso che il mio compilatore sia stato aggiornato o patchato.

Potrebbe anche essere utile pubblicare un file sorgente molto breve ma completo che riproduca il problema. Penso che ti mancino solo le dichiarazioni di inclusione qui?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top