HOWTO compile and use the mpatrol memory leak detection library

1. Download the latest MinGW automated Installer from:
http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/

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:
https://mpatrol.svn.sourceforge.net/svnroot/mpatrol/branches/AUTOTOOL
or using your web browser from:
http://mpatrol.svn.sourceforge.net/viewvc/mpatrol/branches/AUTOTOOL/
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
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config-dev_0.25-1_win32.zip
and copy pkg.m4 from share\local (after the extraction of course) to
c:\MinGW\share\aclocal\

This 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:

http://trac.enlightenment.org/e/wiki/EFLWindowsXP#Dependencies
http://trac.enlightenment.org/e/wiki/EFLWindowsXP#Configuration
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

$ ./configure 

8. Run

$ make 

9. Run

$ make install 

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

$ ./test1 

You should get a valid mpatrol.log. To find out what a valid log is check out the mpatrol documentation http://mpatrol.sourceforge.net/doc/files/mpatrol.pdf
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

$ export MPATROL_OPTIONS="LOGALL" 

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

$ export MPATROL_OPTIONS="LOGALL SHOWFREE SHOWUNFREED" 

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

Site Status

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