[Cppunit-devel] getting started with cppunit
Brought to you by:
blep
From: Richard U. <ric...@im...> - 2002-09-12 06:43:06
|
Hi, I am new with cppunit, but when I try out the very first example from the cookbook, the linker exits with errors. I think, the package is well installed on my linux machine within: /usr/local/stow/cppunit-1.8.0 I added /usr/local/stow/cppunit-1.8.0/include to PATH I copied libcppunit.a to my working dir: ~cppunit I created the file complex.cpp, tried to compile with: g++ libcppunit.a complex.cpp and got the errors at the end of the message can you help me or give me a working example? thanks Richard ================================================================= complex.cpp: =========== #include <sstream> using namespace std; #include "cppunit/TestCase.h" using namespace CppUnit; class Complex { friend bool operator==(const Complex &a, const Complex &b); double real, imaginary; public: Complex(double r, double i=0) :real(r), imaginary(i) {} }; bool operator==( const Complex &a, const Complex &b ){ bool b0=false; b0 = (a.real== b.real) && (a.imaginary == b.imaginary); return b0; //return eq(a.real, b.real) && eq(a.imaginary, b.imaginary); } class ComplexNumberTest : public CppUnit::TestCase{ public: ComplexNumberTest( std::string name ) : CppUnit::TestCase( name ) {} ComplexNumberTest( ) : CppUnit::TestCase( ) {} void runTest(){ CPPUNIT_ASSERT( Complex(10,1) == Complex (10,1) ); CPPUNIT_ASSERT( !(Complex(1,1) == Complex (2,2)) ); } }; int main(int argc, char** argv) { //string myname; ComplexNumberTest *mytest; mytest = new ComplexNumberTest(); return 0; } ================================================================= ================================================================= /tmp/ccLCWwmm.o(.rodata+0xa8): undefined reference to `CppUnit::TestCase type_info node' /tmp/ccLCWwmm.o: In function `ComplexNumberTest::ComplexNumberTest(void)': /tmp/ccLCWwmm.o(.ComplexNumberTest::gnu.linkonce.t.(void)+0xf): undefined reference to `CppUnit::TestCase::TestCase(void)' /tmp/ccLCWwmm.o(.ComplexNumberTest::gnu.linkonce.t.(void)+0x3d): undefined reference to `CppUnit::TestCase::~TestCase(void )' /tmp/ccLCWwmm.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0xc): undefined reference to `CppUnit::TestCase::run(CppUnit::Tes tResult *)' $ g++ libcppunit.a complex.cpp /tmp/cc6dkxjM.o(.rodata+0xa8): undefined reference to `CppUnit::TestCase type_info node' /tmp/cc6dkxjM.o: In function `ComplexNumberTest::ComplexNumberTest(void)': /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.(void)+0xf): undefined reference to `CppUnit::TestCase::TestCase(void)' /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.(void)+0x3d): undefined reference to `CppUnit::TestCase::~TestCase(void)' /tmp/cc6dkxjM.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0xc): undefined reference to `CppUnit::TestCase::run(CppUnit::TestResult *)' /tmp/cc6dkxjM.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0x10): undefined reference to `CppUnit::TestCase::countTestCases(void) const' /tmp/cc6dkxjM.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0x14): undefined reference to `CppUnit::TestCase::getName(void) const' /tmp/cc6dkxjM.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0x18): undefined reference to `CppUnit::TestCase::toString(void) const' /tmp/cc6dkxjM.o(.gnu.linkonce.d.__vt_17ComplexNumberTest+0x1c): undefined reference to `CppUnit::TestCase::run(void)' /tmp/cc6dkxjM.o: In function `ComplexNumberTest::~ComplexNumberTest(void)': /tmp/cc6dkxjM.o(.gnu.linkonce.t._._17ComplexNumberTest+0x21): undefined reference to `CppUnit::TestCase::~TestCase(void)' /tmp/cc6dkxjM.o: In function `ComplexNumberTest type_info function': /tmp/cc6dkxjM.o(.gnu.linkonce.t.__tf17ComplexNumberTest+0x10): undefined reference to `CppUnit::TestCase type_info function' /tmp/cc6dkxjM.o: In function `ComplexNumberTest::runTest(void)': /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.runTest(void)+0x45): undefined reference to `CppUnit::SourceLine::SourceLine(basic_string<char, stri ng_char_traits<char>, __default_alloc_template<true, 0> > const &, int)' /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.runTest(void)+0xc1): undefined reference to `CppUnit::Asserter::failIf(bool, basic_string<char, stri ng_char_traits<char>, __default_alloc_template<true, 0> >, CppUnit::SourceLine)' /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.runTest(void)+0x120): undefined reference to `CppUnit::SourceLine::SourceLine(basic_string<char, str ing_char_traits<char>, __default_alloc_template<true, 0> > const &, int)' /tmp/cc6dkxjM.o(.ComplexNumberTest::gnu.linkonce.t.runTest(void)+0x197): undefined reference to `CppUnit::Asserter::failIf(bool, basic_string<char, str ing_char_traits<char>, __default_alloc_template<true, 0> >, CppUnit::SourceLine)' collect2: ld returned 1 exit status $ -- =============================================================== Richard Uhlmann Tel.: ++49-9131/7518-47 imbus AG Fax: ++49-9131/7518-50 Kleinseebacherstr. 9 D-91096 Moehrendorf http://www.imbus.de Germany email: ric...@im... =============================================================== |