CppUnit on Linux (Console and Eclipse)

Compilation

Get cppunit-1.10.2.tar.gz and extract the contents:

tar -xzf cppunit-1.10.2.tar.gz

Go into the created directory:

cd cppunit-1.10.2

Run configuration script in that directory:

./configure

Build the contents:

make

As super user (root) install the cppunit to your system:

make install

See where the library files ended up:

./cppunit-config --libs

Output on my installation is as follows: -L/usr/local/lib -lcppunit -ldl

Now you should be able to compile stuff from console. Get the samples and after extracting the file, compile the contents:

gcc -L/usr/local/lib -lcppunit -ldl main.cpp

Note the options sent to gcc are the output of the cppunit-config script.

Running

To run the output of the compilation, you will need to get your library into the correct directory. The following line was seen to be working on a Debian (testing) system:

ln -s /usr/local/lib/libcppunit-1.10.so.2.0.0 /usr/lib/libcppunit-1.10.so.2

/usr/local/lib/libcppunit-1.10.so.2.0.0 is the actual location of the installed library.

/usr/lib/libcppunit-1.10.so.2 is the address of the symbolic link, necessary for the compiler (gcc) to recognise the CppUnit includes. These addresses may be needed to be altered for your system although unlikely.

Eclipse Configuration

After these steps, if and only if you can compile and run CppUnit projects, you can add this functionality to Eclipse by following these steps:

Create a Managed Make C++ Project

Import sample mentioned above to your project by using Import > General > File System

Goto Project Properties > C/C++ Build > Tool Setings > GCC C++ Linker > Libraries and add the output of the cppunit-config --libs command here as well. For example for the above configuration, lines are:

Click add for the top window, note that this window is for the -l, therefore first add this line:

cppunit

click ok, and add another line:

dl

Then in the bottom window add this line:

/usr/local/lib

That is all for now, click ok and build again, you should have a binary created for you now. Note that the lines entered may be different if you used different lines for the previous parts.

Reference: CppUnitWithEclipse

CppUnitOnLinux (last edited 2008-02-26 06:29:55 by localhost)

SourceForge.net Logo