Skip to content

Building Visual Leak Detector from Source

Arkady Shapkin edited this page Mar 31, 2017 · 3 revisions

Because Visual Leak Detector is open source, it can be built from source if you want to tweak it to your liking. As of Visual Studio 2008, the source can usually be built out-of-the-box without downloading or installing any other tools. If you are using Visual Studio 2008 (or later), you can skip ahead to Executing Your Built vld.dll.

Users with older versions of Visual Studio should continue reading here and follow the instructions in the next subsection.

For Older Versions of Visual Studio The most difficult part about building VLD from source is getting your build environment correctly set up. But if you follow these instructions carefully, the process should be fairly painless.

  1. VLD depends on the Debug Help Library. This library is part of Debugging Tools for Windows (DTfW). Download and install DTfW in order to install the required headers and libraries. I recommend installing version 6.5 of DTfW, or later. Newer versions tend to work fine, but older versions will probably not work. Be sure to manually select to install the SDK files during the DTfW installation or the headers and libraries will not be installed (they are not always installed with a default installation).
  2. Visual C{"++"} will need to be made aware of where it can find the Debug Help Library header and library files. Add the sdk\inc and sdk\lib\i368 (sdk\lib\amd64) subdirectories from the DTfW installation directory to the include and library search paths in Visual C{"++"}. (See the section above on using Visual Leak Detector on instructions for adding to these search paths).
  3. VLD also requires a reasonably up-to-date Microsoft Windows SDK. It is known to work with the latest SDK (as of this writing) which is the Microsoft Windows SDK for Windows 7 and .NET Framework 4. It should also work with earlier SDKs, such as the Windows XP SP2 SDK. If in doubt, update your Microsoft Windows SDK to the latest version.
  4. Again, Visual C{"++"} will need to know where to find the Microsoft Windows SDK headers and libraries. Add the Include and Lib subdirectories from the Platform SDK installation directory to the Include and Library search paths, respectively. The Microsoft Windows SDK directories should be placed just after the DTfW directories. To summarize, your Visual C{"++"} include search path should look something like this:
C:\Program Files\Debugging Tools for Windows (x86)\sdk\inc 
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include 
C:\Program Files\Microsoft Visual Studio x\VC\Include 
... 

And your Visual C{"++"} library search path should look like this:

C:\Program Files\Debugging Tools for Windows (x86)\sdk\lib\i386
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib 
C:\Program Files\Microsoft Visual Studio x\VC\Lib 
... 

In the above examples, "x" could be "8", "9.0", or "10.0" (or possibly other values) depending on which version of Visual Studio you have installed. Also, the name of your Microsoft Windows SDK directory will probably be different from the example depending on which version of the Platform SDK you have installed.

Once you have completed all of the above steps, your build environment should be ready. To build VLD, just open the vld.sln solution file and do a full build.

Executing Your Built vld.dll When actually running the built project, vld.dll will expect to find the Debug Help Library as a private assembly. The private assembly must be located in the same directory as vld.dll (either the Release or Debug directory by default). Otherwise, when VLD is loaded, an error message will pop up indicating that the program failed to initialize, and you will see a message similar to the following in the debugger's output window:

_LDR: LdrpWalkImportDescriptor() failed to probe C:\Projects\vld\Release\vld.dll for its manifest, ntstatus 0xc0150002_

To ensure that vld.dll finds the required private assembly, you need to copy dbghelp.dll and Microsoft.DTfW.DHL.manifest to the same directory that vld.dll is in.