Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 07-31-2003, 02:09 AM   #1
LQ Newbie
Registered: Jul 2003
Location: India
Distribution: redhat
Posts: 11

Rep: Reputation: 0
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 {
Complex *m_10_1, *m_1_1, *m_11_2;
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) );
/* void testAddition()
CPPUNIT_ASSERT( *m_10_1 + *m_1_1 == *m_11_2 );

int main( void)

CppUnit::TextUi::TestRunner runner;
CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
runner.addTest( registry.makeTest() );
bool wasSucessful = "", 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:

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/'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ld linking problem captain-mythos Linux - Software 1 06-20-2004 08:46 AM
C++ Linking Problem acjt Programming 4 01-31-2004 08:48 AM
Cppunittest- problem with linking!!! prai Programming 5 08-01-2003 12:37 AM
Problem linking Red Guy Programming 1 02-07-2003 03:52 AM
linking problem with ld ! gluon Programming 2 05-19-2002 01:59 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration