| crashrpt |
A crash reporting system for Windows applications

# Compiling CrashRpt

By default, CrashRpt archive's bin directory contains binary files compiled in Visual Studio 2010. These files are provided for demonstration purposes only. It is strongly recommended that you compile CrashRpt yourself using your version of Visual Studio. This is needed to ensure CrashRpt uses the same version of C run-time libraries (CRT) as your application does.

## Building Solution

The top-level directory of CrashRpt distribution contains solution file for Visual Studio 2010 (CrashRpt_vs2010.sln). Open this solution file to compile CrashRpt in Visual C++ 2010 or in Visual C++ Express 2010.

If you use another version of Visual Studio, you can generate solution/project files for your version of Visual Studio using CMake. See below for instructions.

## Generating Project Files with CMake

Since v.1.3.0, you can generate Visual Studio project files using CMake cross-platform make system. Although CrashRpt doesn't support operating systems other than Windows and doesn't support compilers other than Visual C++, CMake is useful, because it makes it easier to maintain multiple build configurations between different versions of Visual Studio.

To generate CrashRpt solution/project files for your favorite version of Visual Studio with CMake, do the following:

- Download CMake (version 2.8 or later) and install it. This will create CMake shortcuts in All Programs menu in the Start menu.
- Run CMake (cmake-gui) application. This will display the cmake-gui window.
- In the Where is the source code: field, enter the path to your top-level directory of CrashRpt distribution. The top-level directory and its subdirectories contain CMakeLists.txt files which are CMake configuration files.
- In the Where to build the binaries: field, enter the path to the directory where you want to generate project files. It is recommended to enter the path to your top-level directory of CrashRpt distribution here, too.
- Press the Configure button. When prompted, select your version of Visual Studio from the list. If everything is OK, you should see the message "Configuring done".
- In the option list, modify build options as you wish.
  - CRASHRPT_BUILD_SHARED_LIBS option controls whether to build CrashRpt as DLL or as a static LIB. It is recommended that you have this checked. Unchecking the option will force CrashRpt to build static libs instead of DLLs.
  - CRASHRPT_LINK_CRT_AS_DLL option controls how CrashRpt should be linked to C run-time (CRT) libraries. Unchecking this option will force CrashRpt to link CRT as a multi-threaded static library. It is recommended that you have this checked, which results in linking CRT as multi-threaded DLL.
- After modifying options, press the Configure button the second time to force changes to make effect. If everything is OK, you should see the message "Configuring done".
- Press the Generate button. This will generate project files to the directory you have specified. If everything is OK, you should see the message "Generating done".
- And finally, go to the directory you have specified in the Where to build the binaries: field. You should see CrashRpt.sln file that you can use to compile CrashRpt.

## CrashRpt Solution Structure

There are several projects in CrashRpt solution.

- CrashRpt project contains API implementation and provides functionality for intercepting exceptions.

- CrashSender project contains functionality for displaying GUI, sending the error report and showing error report sending progress.

- CrashRptTest is a GUI application that helps to test that CrashRpt API functions work as expected.

- crashcon is a console application that helps to test how CrashRpt works with console applications.

- zlib project contains file compression functionality.

- libpng project contains PNG file management functionality.

- jpeg project contains JPEG file management functionality.

- minizip project contains ZIP file management functionality.

- CrashRptProbe project contains functionality for processing error reports.

- crprober is a console tool for error reports processing.

- Tests project contains automated tests.

To build the solution, choose the Release build configuration and press F7 to start building process.

## Compilation for 64-bit (x64) Platform

Since v.1.2.1, CrashRpt can be compiled for both 32-bit (Win32) and 64-bit (x64) platforms. You can choose the current platform by opening menu Build->Configuration Manager... and by selecting the desired platform from the 'Active solution platform:' combo box.

If you use CMake to generate project files, select a 64-bit compiler from the drop-down list when configuring CMake.

You should have x64 compiler tools and SDK files properly installed (ensure you have checked these components during Visual C++ installation).

## Notes About Compiling in Visual C++ Express

Compilation in free Visual C++ Express is a little more complicated than compilation in a commercial edition of Visual C++.

CrashRpt depends on WTL. WTL itself depends on Microsoft's library called ATL (Active Template Library). ATL library is a part of Visual Studio SDKs. An older version, ATL 3.0, is included into Microsoft Platform SDK for Windows Server 2003. Since then, Platform SDK was renamed into Windows SDK. However, Microsoft doesn't include ATL into Windows SDK to encourage using of commercial Visual Studio having ATL.

So, there are two ways to compile CrashRpt in Visual C++ Express:

The first way. You need to have Platform SDK for Windows Server 2003, because this Platform SDK contains ATL 3.0 source code. Download and install Microsoft Platform SDK for Windows Server 2003, for example from here.

In VC++ Express window, open Tools->Options...->Projects and Solutions-> VC++ Directories. In the 'Show directories for' combo, select 'Include files' and then add <Platform_SDK_Folder>\Include\atl path to the list of include directories (replace the <Platform_SDK_Folder> with the actual directory name).

The second way. Install Windows Driver Kit, version 7.0 or later, because it contains ATL 7.1 source code. When WinDDK is installed, in VC++ Express window, open Tools->Options...->Projects and Solutions-> VC++ Directories. In the 'Show directories for' combo, select 'Include files' and then add C:\WinDDK\6001.18002\inc\crt\atl71 path to the list of include directories.

## Generating Project Documentation

By default, project documentation is already generated and included into the CrashRpt distribution. To open the documentation, click `index.html` file in the top-level directory of CrashRpt distribution.

You can also build documentation yourself. CrashRpt documentation can be generated using the Doxygen tool. You can download the tool from here.

To build the documentation, go to the `docs` folder and type in the command line:

    doxygen Doxyfile

When doxygen finishes, go to the top level directory and open `index.html`.

## FAQ

What is the Release LIB build configuration?

The Release LIB configuration is an addition to the standard Debug and Release build configurations. Typically, you do not compile CrashRpt in this configuration. However, it may be useful if you use static CRT linkage.

In the Release LIB configuration, the build generates CrashSender.exe executable file and CrashRptLIB.lib static library. In this configuration, CrashSender.exe and CrashRptLIB.lib use static linkage to CRT.