VS linker can't find the symbols that are supposed to be in cppunit library. So either you did not specify that your project links to the cppunit library (1), or you did, but the symbols are not present in it (2):
0. As a sanity check, can you find the cppunit(d).lib library the linker directory you specified? Furthermore if it's DLL, is the DLL there as well?
1. Did you specify that your test project really links to cppunit.lib (or cppunitd.lib, or whatever .lib name is in the directory from point 0.)? At least you did not write it in your info. This is set in Linker -> Input -> Additional Dependencies
2. Further, in case you are using cppunit as DLL, did you specify (or was it already specified) macro "CPPUNIT_BUILD_DLL" in project settings of cppunit itself when building it? Right-click on cppunit project, then Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor definitions? (In case you are using static lib, specifying this macro should not hurt either, I am not sure if __declspec(dllexport) plays any role in static libs as it does in DLLs).
Furthermore, in points 1. and 2., can you as well make sure, that the needed settings are present for both Debug and Release (or, in general, for all configurations you use)?
Cheers,
Boris Dušek
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Okay I'm hoping you guys can help me.
I have compiled CPPUnit 1.12.0 from within Visual Studios 2003 on Windows XP SP2.
I have removed the DSPlugin to avoid some errors.
I have created a AppMain.cpp file, a AppTestCase.cpp/.h file.
I have added the include directory to the projects "C++..General...Additional Include Directories".
I have added the lib directory that was created to the "Linker...General..Additional Library Directories".
Once I try compiling my new code and test cases, I get the following:
AppTestCase fatal error LNK1120: 24 unresolved externals
AppTestCase error LNK2001: unresolved external symbol "public: static class CppUnit::TestFactoryRegistry & __cdecl CppUnit::TestFactoryRegistry::getRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getRegistry@TestFactoryRegistry@CppUnit@@SAAAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::BriefTestProgressListener::BriefTestProgressListener(void)" (??0BriefTestProgressListener@CppUnit@@QAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::CompilerOutputter::CompilerOutputter(class CppUnit::TestResultCollector *,class std::basic_ostream<char,struct std::char_traits<char> > &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0CompilerOutputter@CppUnit@@QAE@PAVTestResultCollector@1@AAV?$basic_ostream@DU?$char_traits@D@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestNamer::TestNamer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0TestNamer@CppUnit@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "private: static class CppUnit::TestNamer const & __cdecl AppTestCase::getTestNamer__(void)" (?getTestNamer__@AppTestCase@@CAABVTestNamer@CppUnit@@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestResult::TestResult(class CppUnit::SynchronizedObject::SynchronizationObject *)" (??0TestResult@CppUnit@@QAE@PAVSynchronizationObject@SynchronizedObject@1@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestResultCollector::TestResultCollector(class CppUnit::SynchronizedObject::SynchronizationObject *)" (??0TestResultCollector@CppUnit@@QAE@PAVSynchronizationObject@SynchronizedObject@1@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestRunner::TestRunner(void)" (??0TestRunner@CppUnit@@QAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestSuite::TestSuite(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0TestSuite@CppUnit@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: static class CppUnit::TestSuite * __cdecl AppTestCase::suite(void)" (?suite@AppTestCase@@SAPAVTestSuite@CppUnit@@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: __thiscall CppUnit::TestSuiteBuilderContextBase::TestSuiteBuilderContextBase(class CppUnit::TestSuite &,class CppUnit::TestNamer const &,class CppUnit::TestFixtureFactory &)" (??0TestSuiteBuilderContextBase@CppUnit@@QAE@AAVTestSuite@1@ABVTestNamer@1@AAVTestFixtureFactory@1@@Z) referenced in function "public: static class CppUnit::TestSuite * __cdecl AppTestCase::suite(void)" (?suite@AppTestCase@@SAPAVTestSuite@CppUnit@@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: static bool __cdecl CppUnit::TestFactoryRegistry::isValid(void)" (?isValid@TestFactoryRegistry@CppUnit@@SA_NXZ) referenced in function "public: __thiscall CppUnit::AutoRegisterSuite<class AppTestCase>::~AutoRegisterSuite<class AppTestCase>(void)" (??1?$AutoRegisterSuite@VAppTestCase@@@CppUnit@@QAE@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: static class CppUnit::TestFactoryRegistry & __cdecl CppUnit::TestFactoryRegistry::getRegistry(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?getRegistry@TestFactoryRegistry@CppUnit@@SAAAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::BriefTestProgressListener::~BriefTestProgressListener(void)" (??1BriefTestProgressListener@CppUnit@@UAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::CompilerOutputter::~CompilerOutputter(void)" (??1CompilerOutputter@CppUnit@@UAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TestNamer::~TestNamer(void)" (??1TestNamer@CppUnit@@UAE@XZ) referenced in function "[thunk]:class TestNamer::AppTestCase `private: static class CppUnit::TestNamer const & __cdecl AppTestCase::getTestNamer__(void)'::`2'::testNamer`local static destructor helper'" (?testNamer@?1??getTestNamer__@AppTestCase@@CAABVTestNamer@CppUnit@@XZ@$AV23@A)
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TestResult::~TestResult(void)" (??1TestResult@CppUnit@@UAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TestResultCollector::~TestResultCollector(void)" (??1TestResultCollector@CppUnit@@UAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TestRunner::~TestRunner(void)" (??1TestRunner@CppUnit@@UAE@XZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual __thiscall CppUnit::TestSuiteBuilderContextBase::~TestSuiteBuilderContextBase(void)" (??1TestSuiteBuilderContextBase@CppUnit@@UAE@XZ) referenced in function "public: static class CppUnit::TestSuite * __cdecl AppTestCase::suite(void)" (?suite@AppTestCase@@SAPAVTestSuite@CppUnit@@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: virtual bool __thiscall CppUnit::TestSuccessListener::wasSuccessful(void)const " (?wasSuccessful@TestSuccessListener@CppUnit@@UBE_NXZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual void __thiscall CppUnit::CompilerOutputter::write(void)" (?write@CompilerOutputter@CppUnit@@UAEXXZ) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual void __thiscall CppUnit::TestResult::addListener(class CppUnit::TestListener *)" (?addListener@TestResult@CppUnit@@UAEXPAVTestListener@2@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual void __thiscall CppUnit::TestRunner::addTest(class CppUnit::Test *)" (?addTest@TestRunner@CppUnit@@UAEXPAVTest@2@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: virtual void __thiscall CppUnit::TestRunner::run(class CppUnit::TestResult &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?run@TestRunner@CppUnit@@UAEXAAVTestResult@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _main
AppTestCase error LNK2019: unresolved external symbol "public: void __thiscall CppUnit::TestFactoryRegistry::registerFactory(class CppUnit::TestFactory *)" (?registerFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTestFactory@2@@Z) referenced in function "public: __thiscall CppUnit::AutoRegisterSuite<class AppTestCase>::AutoRegisterSuite<class AppTestCase>(void)" (??0?$AutoRegisterSuite@VAppTestCase@@@CppUnit@@QAE@XZ)
AppTestCase error LNK2019: unresolved external symbol "public: void __thiscall CppUnit::TestFactoryRegistry::unregisterFactory(class CppUnit::TestFactory *)" (?unregisterFactory@TestFactoryRegistry@CppUnit@@QAEXPAVTestFactory@2@@Z) referenced in function "public: __thiscall CppUnit::AutoRegisterSuite<class AppTestCase>::~AutoRegisterSuite<class AppTestCase>(void)" (??1?$AutoRegisterSuite@VAppTestCase@@@CppUnit@@QAE@XZ)
I'm sure I am probably missing something, but I can't seem to find anything anywhere else. Got any ideas what I could be doing wrong?
Eric
Hi,
VS linker can't find the symbols that are supposed to be in cppunit library. So either you did not specify that your project links to the cppunit library (1), or you did, but the symbols are not present in it (2):
0. As a sanity check, can you find the cppunit(d).lib library the linker directory you specified? Furthermore if it's DLL, is the DLL there as well?
1. Did you specify that your test project really links to cppunit.lib (or cppunitd.lib, or whatever .lib name is in the directory from point 0.)? At least you did not write it in your info. This is set in Linker -> Input -> Additional Dependencies
2. Further, in case you are using cppunit as DLL, did you specify (or was it already specified) macro "CPPUNIT_BUILD_DLL" in project settings of cppunit itself when building it? Right-click on cppunit project, then Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor definitions? (In case you are using static lib, specifying this macro should not hurt either, I am not sure if __declspec(dllexport) plays any role in static libs as it does in DLLs).
Furthermore, in points 1. and 2., can you as well make sure, that the needed settings are present for both Debug and Release (or, in general, for all configurations you use)?
Cheers,
Boris Dušek