Revision of HOWTO compile and use the mpatrol memory leak detection library from 2011, March 28 - 09:30

Printer-friendly version

1. Download the latest MinGW automated Installer from

2. Run it, select Download latest repository catalogues, then select all components to be installed (you need C and C++ compilers, if you want you can leave out the other three - Fortran, ObjC, Ada)

3. Once MinGW is installed download the autotooled mpatrol version (we have it thanks to Vincent Torri) either from the SVN repository via an SVN client:
or using your web browser from:

 click * Download GNU tarball * at the bottom

4. Extract the files to some temporary folder

5. Run Start Menu >> Programs >> MinGW >> MinGW Shell

6. Navigate to your temporary folder using the "cd" command

7. Run

$ autoreconf -f -i 

8. If you do not have the pkg-config program installed (and this is the case if you installed a fresh MinGW installation), download this file
and copy pkg.m4 from share\local (after the extraction of course) to
c:\MinGW\share\aclocalThis doesn't install the pkg-config program, it's just a necessity so that the configure script doesn't crash.
If you want to install and use the pkg-config utility check out this tutorial:
you’re interested mostly in this line:
> Untar glib 2.26.1, pkg-config 0.25 and intl 0.18 in /usr/local, and pkg-config 0.25 dev (for pkg.m4) in C:\MinGW

7. Run

 <pre>$ ./configure </pre.

8. Run

 <pre>$ make </pre>

9. Run

 <pre>$ make install </pre>

10. You're done. Navigate to directory tests in your temporary folder, then to the subdirectory fail and compile the test program using this command

$ gcc -I/usr/local/include/mpatrol-1 test1.c -o test1 -L/usr/local/lib -lmpatrol -lbfd -liberty -limagehlp -lintl 

Run the output using

 <pre>$ ./test1 </pre>

You should get a valid mpatrol.log. To find out what a valid log is check out the mpatrol documentation
I recommend compiling some more test programs. Instead of environment variables in Windows you can use the export command. Type this before executing the test program


To use multiple different options simply divide them by a space character


11. Now you're ready to explore the underworld of memory leaks ;)

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC