[Cppunit-devel] linker errors
Brought to you by:
blep
|
From: <ad...@gu...> - 2002-08-27 12:28:47
|
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:
//__________________________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
//__________________________Employ1Test.cpp_________________________
#include "Employ1Test.h"
#include "Employ1.h"
CPPUNIT_TEST_SUITE_REGISTRATION( Employ1Test );
//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);
}
//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" );
}
//__________________________Employ1.h_________________________
#ifndef EMPLOY1_H
#define EMPLOY1_H
class Employee
{
public:
Employee(const char*, const char*); //constructor
~Employee(); //destructor
const char *getFirstName() const;
const char *getLastName() const;
//static member function
static int getCount();
private:
char *firstName;
char *lastName;
//static data member
static int count;
};
#endif
//__________________________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; }
|