Eclipse - CppUnit - Installation

It is a bit complex to know how to install CppUnit and how to use it with Eclipse.

That's why I make this tutorial about CppUnit and Eclipse.
I hope it will be easy enough even for beginners, if not, do not hesitate to post a comment, I will help if I can.

This installation will be done on Windows OS, I am sure if you are a Linux addict or a Mac fan, this explanation will help you as well.

1. Installation of CppUnit with Eclipse on Windows

A. The CppUnit framework

Of course, we need the source of the CppUnit framework.
No problem there, take it up from the official host website:

So extract all the files on the directory of your choice, for example, I will put them in this one:

We need now to configure the framework.
At this point, you need at least a GNU tool for Windows, such as MinGW. If you don't have it, check on my website, and follow instructions.
If you installed MinGW without Make, you should also need the MSys, a brother of MinGW.
MSys contains the GNU Make tool.
So, open MinGW and go until the directory where you put CppUnit, in our case:

Execute the following command:


Once it done, execute this second one:


To finish execute this last one:

make install

Don't be afraid, it may take at least 10 minutes for the 3 commands to be performed.

OK, if you don't have any error, CppUnit is now configured for your system.
That's a great step.

B. CppUnit with Eclipse

Open Eclipse then create a new C++ Project.
The Project name is MyCppUnitStaticLibrary, its type is an empty Static Library, and the Toolchain is MinGW GCC.
For example File > New > C++ Project > Static Library > Empty Project > MinGW GCC > Finish.
Really basic.

Open this project and create a new folder inside, such as myimports.
Right click this new folder and select Import > General > File System > Next.
In the From directory input, click Browse and enter the directory where you put the CppUnit source, in our case: C:\soft\libraries\cppunit-1.12.1\src\cppunit.

Click Select All > Finish.
It will import all files from src/cppunit into myimports.

OK, let's continue by right clicking the project then > Properties > C/C++ Build > Settings >Tool SettingsGCC C++ Compiler > Includes.
Click Add... on the right (a tiny icon with a green plus) to add a directory path.
In our case it will be: C:\soft\libraries\cppunit-1.12.1\include.
Click OK > OK.

Our project library is now ready to be built.
So let's do it.
Right click the project then > Build Project.

A new lib has been created in the Debug folder: libMyCppUnitStaticLibrary.a.

Let's continue.

Create a new C++ Project named MyNewProject.
File > New > C++ Project > Executable > Empty Project > MinGW GCC > Finish.

Right click MyNewProject > Properties > C++ Build > Settings > Tool Settings > GCC C++ Compiler > Includes.
On the right, click the tiny green icon on the Include paths (-I) panel and add this:
Click OK.

Let's continue.
MyNewProject > Properties > C++ Build > Settings > Tool Settings > MinGW C++ Linker > Libraries.
On the right there are two panes.
On the first, at top, Libraries (-l), click the green plus icon and add this: MyCppUnitStaticLibrary.
Indeed, in C++ we must not use the prefix lib and the .a extension.
The main reason is that the linker doesn't accept it.

In the second pane, at bottom, Library search path (-L), let's enter in which directory this lib is.
So let's add it, in my case it is: C:\dev\cpp\MyCppUnitStaticLibrary\Debug.
Click OK.

Here we are, let's test it!

In the cppunit sources that you have installed, there is a folder named examples:

Open it and copy paste the money folder into your MyNewProject.
Build this project (rigth click > Build Project).

Once it done, right click again this project > Run As > Local C/C++ Application.

In the console we can see four full stops (....) with an OK and (4).
Just like that:


OK (4)

It means that your installation of CppUnit with Eclipse on Windows is completed!
You are now ready to use it.
Well done you've made it! laugh



Thanks for the installation tutorial.

It helps a lot.

I used Cygwin. The only difference for using cygwin is that you must use relative directory instead of absolute directory. "C:\dev\...." . need delete "C:\"


Thank you for the Cygwin way of using Eclipse and CppUnit. laugh


After building the project, I get varoius errors complaining that it can't find certain header files:

../myimports/src/qttestrunner/MostRecentTests.h:10:21: warning: qstring.h: No such file or directory

Has anyone else come across these, or got a solution to it?

It would be much appreciated! This tutorial is great by the way.



'src/cppunit' not 'src'


Thanks for the great explanation! I installed all from scratch, run it and with no mistakes! Great tutorial


Thank you very much.

It was hard when installing cppunit with MSYS , there was message " No rule to make targe '../../config/ac_create_prefix_config_h.m4'  ..." , just problem of correct cppunit download. 

Now money examples is ok. I should go next step, thanks again


I suceeded thanks to your tutorial. I'm greatful. 

Nevertheless I've got some error messages when I ran the command "make" and the command 'make install".

Error message: 'failcom' isn't recognized as an internal command

'failcom' appears in the Makefile.

Despite that, I've got the right message on Eclipse, so it seems like it's working !


Thanks a bunch for the tutorial! Most Helpful!

I installed using cygwin also and it worked great... until I got to the money example.

Upon building the example, I get an error in the makefile (pasted below). Has anyone else seen this?


Building target: MyNewProject.exe
Invoking: Cygwin C++ Linker
g++ -L"C:\Data\Projects\MyCppUnitStaticLibrary\Debug" -o "MyNewProject.exe" ./money/MoneyApp.o ./money/MoneyTest.o ./money/StdAfx.o -lMyCppUnitStaticLibrary.a
/usr/lib/gcc/i686-pc-cygwin/4.9.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lMyCppUnitStaticLibrary.a
collect2: error: ld returned 1 exit status
makefile:45: recipe for target 'MyNewProject.exe' failed
make: *** [MyNewProject.exe] Error 1


This is a great tutorial to start..
i followed each step, but after building the project
certain errors came like this
---undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'-----------

please help me to rectify and build the project


Thank you very much. This post is very useful for me to execute cppunit.


Thanks you very much.
How I can build cppunit source in Linux on Eclipse.


I also want to thank you very much. It took some time but now it should work :-)
To those guys that had the Problem with "cannot find -lMyCppUnitStaticLibrary.a" (I know it was 2015 but I had the same Problem). Make sure that the Project type of "MyCppUnitStaticLibrary" is an empty Static Library! (the very beginning of Step B). That was the mistake I did several times and wondered why libMyCppUnitStaticLibrary.a was not created. So best regards

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.