2009-01-29 32 views
0

當編譯我的測試套件反對票的CppUnit,我得到了鏈接錯誤如下:CppUnit的鏈接錯誤

error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TextTestRunner::~TextTestRunner(void)" ([email protected]@@[email protected]) 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; 
} 

回答

2

您是否確定已將相應的庫添加到項目的鏈接器 - >輸入 - >附加相關性文本框中?我相信這應該是(對於發佈/ Unicode版本):

testrunneru.lib cppunit.lib

您還需要確保鏈接器可以通過添加適當的目錄名鏈接器找到庫 - >常規 - >附加庫目錄。

真正的舒展,但它發生在我身上,是我需要重建cppunit。我認爲我的編譯器已升級或修補。

如果您可以發佈一個非常簡短但完整的源文件來重現問題,它可能也會有所幫助。我想你只是想念這裏的包含陳述?

+0

做到了這一點,沒有快樂 – cbrulak 2009-01-29 18:42:04