Re: [Cppunit-devel] linker errors
Brought to you by:
blep
From: Baptiste L. <gai...@fr...> - 2002-08-27 18:19:04
|
See FAQ item 2.2: http://cppunit.sourceforge.net/FAQ Baptiste. ----- Original Message ----- From: "André Dhondt" <ad...@gu...> To: <cpp...@li...>; <da...@re...> Sent: Tuesday, August 27, 2002 2:28 PM Subject: [Cppunit-devel] linker errors > CPPUnit developers: > > Sorry if this isn't the right forum for asking for support, but if it is, > could you please help??? > > I just downloaded ver. 1.8.0 of CppUnit, followed the directions for running > the HostApp examples, and everything worked fine. On a Win32 platform with > Visual C++ 6.0, I then attempted to use the TestRunner Gui (as per the > INSTALL-WIN32.txt instructions), but I get linker errors as follows: > > Linking... > msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall > std::basic_string<char,struct std::char_traits<char>,class > std::allocator<char> >::basic_string<char,struct > std::char_traits<char>,class std::allocator<char> >(class > basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::basic_string<char,struct std::char_traits<char>,class > std::allocator<char> > const &)" > (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@ > Z) already defined in Employ1Test.obj > > Since I'm a C++ newbie, I'd just like to know where I should be looking for > problems. Source code included below: > > file://__________________________Employ1Test.h_________________________ > #ifndef _EMPLOYTEST_H > #define _EMPLOYTEST_H > > #include <cppunit/TestCase.h> > #include <cppunit/extensions/HelperMacros.h> > > class Employ1Test : public CppUnit::TestCase > { > CPPUNIT_TEST_SUITE( Employ1Test ); > CPPUNIT_TEST( testCreateEmployee ); > CPPUNIT_TEST( testGetEmployeeName ); > CPPUNIT_TEST_SUITE_END(); > protected: > void testCreateEmployee( void ); > void testGetEmployeeName( void ); > }; > > > #endif // _EMPLOYTEST_H > > file://__________________________Employ1Test.cpp_________________________ > #include "Employ1Test.h" > #include "Employ1.h" > > CPPUNIT_TEST_SUITE_REGISTRATION( Employ1Test ); > > file://simply verifies the constuctors don't crash the app > void Employ1Test::testCreateEmployee( void ) > { > Employee *e1 = new Employee("Susan","Baker"); > Employee *e2 = new Employee("Robert","Jones"); > CPPUNIT_ASSERT( (int)e2->getCount == (int)2); > } > > file://verifies the constructors set the properties as expected, and that we can > retrieve the values > void Employ1Test::testGetEmployeeName( void ) > { > Employee *e1 = new Employee("Susan","Baker"); > Employee *e2 = new Employee("Robert","Jones"); > CPPUNIT_ASSERT( e1->getFirstName() == "Susan" ); > } > > file://__________________________Employ1.h_________________________ > #ifndef EMPLOY1_H > #define EMPLOY1_H > > class Employee > { > public: > Employee(const char*, const char*); file://constructor > ~Employee(); file://destructor > const char *getFirstName() const; > const char *getLastName() const; > > file://static member function > static int getCount(); > > private: > char *firstName; > char *lastName; > > file://static data member > static int count; > }; > > #endif > > file://__________________________Employ1.cpp_________________________ > #include <iostream> > > using std::cout; > using std::endl; > > #include <cstring> > #include <cassert> > #include "employ1.h" > > int Employee::count = 0; > > int Employee::getCount() {return count;} > > Employee::Employee(const char *first, const char *last) > { > firstName = new char[strlen(first) + 1]; > assert(firstName != 0); > strcpy(firstName, first); > > lastName = new char[strlen(last) + 1]; > assert(lastName != 0); > strcpy(lastName, last); > > ++count; > cout << "Employee constructor for " << firstName << > ' ' << lastName << " called." << endl; > > } > > Employee::~Employee() > { > cout << "~Employee() called for " << firstName << > ' ' << lastName << "." << endl; > delete [] firstName; > delete [] lastName; > --count; > } > > const char *Employee::getFirstName() const > { return firstName; } > > const char *Employee::getLastName() const > { return lastName; } > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppunit-devel > |