Cppunittest- problem with linking!!!
I want to test my C++ files using CppUnitTest and i'm new to CppunitTest.
the programi use to test is as below :
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "Complex.h"
class ComplexNumberTest : public CppUnit::TestFixture {
private:
Complex *m_10_1, *m_1_1, *m_11_2;
protected:
void setUp()
{
m_10_1 = new Complex( 10, 1 );
m_1_1 = new Complex( 1, 1 );
m_11_2 = new Complex( 11, 2 );
}
void tearDown()
{
delete m_10_1;
delete m_1_1;
delete m_11_2;
}
void testEquality()
{
CPPUNIT_ASSERT( *m_10_1 == *m_10_1 );
CPPUNIT_ASSERT( !(*m_10_1 == *m_11_2) );
}
public:
ComplexNumberTest(){}
/* void testAddition()
{
CPPUNIT_ASSERT( *m_10_1 + *m_1_1 == *m_11_2 );
}*/
};
int main( void)
{
CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSucessful = runner.run( "", false );
return wasSucessful;
}
when i run this i get an error of this kind:
/tmp/ccasgxgN.o: In function `main':
/tmp/ccasgxgN.o(.text+0x1b): undefined reference to `CppUnit::TextUi::TestRunner::TestRunner[in-charge](CppUnit::Outputter*)'
/tmp/ccasgxgN.o(.text+0x23): undefined reference to `CppUnit::TestFactoryRegistry::getRegistry()'
/tmp/ccasgxgN.o(.text+0x48): undefined reference to `CppUnit::TextUi::TestRunner::addTest(CppUnit::Test*)'
/tmp/ccasgxgN.o(.text+0x88): undefined reference to `CppUnit::TextUi::TestRunner::run(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, bool, bool)'
/tmp/ccasgxgN.o(.text+0xf4): undefined reference to `CppUnit::TextUi::TestRunner::~TestRunner [in-charge]()'
/tmp/ccasgxgN.o(.text+0x10e): undefined reference to `CppUnit::TextUi::TestRunner::~TestRunner [in-charge]()'
collect2: ld returned 1 exit status
when compling i have included the include dir of cppunit. So what else needs to be done. help me out
and what does the following line mean
Libraries have been installed in:
/home/prai/Mailfolder/cppunit-1.8.0/lib/
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
regards
rai
|