Root > Advanced topics > Working with EurekaLog settings > Compiling your project with and without EurekaLog

Compiling your project with and without EurekaLog

Previous pageReturn to chapter overviewNext page   

This is a detailed article. If you want a quick practical example, see: How to enable EurekaLog for production, disable for development?

 


 

Important Note: Be extra careful when doing batch compilation of projects in project groups, or using external build tools. There are IDE bugs and other issues, which may pass incorrect information to EurekaLog (via OpenTools API in case of IDE). Pay close attention which settings file is passed to compilers by external build tools. Always double-check the final executables.

 

A common task for developers is compiling their projects with or without EurekaLog. For example, a developer may want to compile a project with EurekaLog for production (release), but compile the same project without EurekaLog for development (debug).

 

This use case have a good reasoning: EurekaLog is production diagnostic tool, which means it is designed to report about problems "post-morten", it also means that EurekaLog uses fast-enough approaches, as opposed to using heavy debugging code. Therefore, it is preferable to use debug tools (such as IDE debugger, debugging memory manager, OS's checked build, etc.) to locate issues while developing applications, and use EurekaLog to catch remaining issues "on the field".

 

And some developers use EurekaLog only for local debugging, so they want to enable EurekaLog for development, but disable it for production.

 

Important Note: This article will discuss the case when you want to have EurekaLog enabled in one build configuration, but not in another. If you want EurekaLog to be enabled for both Debug and Release build configurations, but with different settings - please, see Different EurekaLog settings for 'Debug' and 'Release' build configurations article instead.

 


 

Anyway, the basic idea is that you (as developer) may want to compile your application with and without EurekaLog. And you also need to do this (i.e. switch build configurations) regularly. There are several possible methods to do this.

 

 

1. (Correct) method #1: Define/Undefine EUREKALOG conditional symbol

EurekaLog units are included in your project like this:

 

program Project1;
 
uses
  {$IFDEF EUREKALOG}
  EMemLeaks,
  EResLeaks,
  EDialogWinAPIMSClassic,
  EDialogWinAPIEurekaLogDetailed,
  EDialogWinAPIStepsToReproduce,
  EDebugExports,
  EFixSafeCallException,
  EMapWin32,
  EAppVCL,
  ExceptionLog7,
  {$ENDIF}
  your-units;

 

Where EUREKALOG symbol is defined in your project options:

 

 

EUREKALOG symbol is defined in project's options

 

Note: EurekaLog post-processing will first check if EUREKALOG symbol is present; if it is not defined - post-processing will be skipped.

 

You may undefine (e.g. remove) EUREKALOG symbol from certain build configurations. Do not remove EUREKALOG_VER7 symbol, remove only EUREKALOG symbol.

 

Important: Please note that settings are inherited. Therefore, you have to remove EUREKALOG symbol from Base build configuration first, then add EUREKALOG symbol to your specific build configuration (Debug, Release, etc.). If you have created additional sub-configurations - be sure not to enable EurekaLog on parent build configurations to avoid inheritance. Typically you are supposed to create your build configurations with EurekaLog disabled - and only enable EurekaLog on "leafs".

 

 

EUREKALOG symbol in Debug build configuration is inherited from Base build configuration

 

You can add/remove EUREKALOG symbol manually, or use EurekaLog project options dialog. You should see "Build Configurations" tab on "General" page:

 

 

Build Configurations tab indicate EurekaLog is enabled for all build configurations

(EurekaLog is enabled in Base build configuration, which means it is inherited to all other build configurations)

 

First, uncheck the "Base" build configuration - this will remove the EUREKALOG symbol from the base build configuration, thus disabling EurekaLog for the entire project. Next, check the desired build configuration:

 

 

EurekaLog is enabled for Debug build configuration only

 

You may want to create additional build configurations:

 

 

Creating a new build configuration

 

 

Custom build configuration is created

 

Important: Be sure to only enable EurekaLog on "leaf" build configurations. Don't forget that settings are inherited, thus you need to enable EurekaLog only in the "leaf" build configurations. Alternatively, you can disable inheritance for symbols manually.

 

Anyway, once a custom build configuration is created - you can enable EurekaLog for it:

 

 

Enable EurekaLog for custom build configuration only

 

If you build your project and your currently selected build configuration does not have the EUREKALOG symbol defined - EurekaLog will detect it and notify you:

 

 

EurekaLog will notify you when it is not enabled in currently active build configuration

 

If it is unexpected - you can either switch to another build configuration (which has EurekaLog enabled), or define the EUREKALOG symbol for the current build configuration - either via project options (manually), or via EurekaLog project options.

 

Important: do not forget to make a full project rebuild (not just compile) when you have switched active build configuration.

 

 

2. (Wrong) method #2: Use "Add EurekaLog to this project" / "Reset"

A wrong way to archive the above mentioned goal is to use "Add EurekaLog to this project" together with "Reset" buttons. The "Add EurekaLog to this project" option will add and configure EurekaLog for the project, "Reset" will remove EurekaLog from the project. While this may work for many projects (basically - for those, which options were not changed much), this option will not get the desired behavior for all cases. The problem is that resetting options will erase all existing EurekaLog options from the project. Therefore, any further "Add EurekaLog to this project" command will simply use defaults. E.g. any changes in settings will be lost.

 

 

3. Method #3: Always compile with EurekaLog, but disable EurekaLog at run-time

One possible method is just have the same executable for all cases. Compile your project with EurekaLog - as you would do it for production/release. Then add check like this at startup:

 

if ThisIsADeveloperMachine then
  SetEurekaLogState(False); // completely disable EurekaLog

 

where ThisIsADeveloperMachine is your custom function to determine if you are running on developer machine or not. You may use IsDebuggerPresent function as ThisIsADeveloperMachine function. Or you may read registry for a specific "magic" value.

 

You may also disable only part of EurekaLog - instead of disabling the entire EurekaLog. For example, you may turn off leaks registering (call EMemLeaks.DisableMemLeaksRegistering). Or you may turn off sending (set CurrentEurekaLogOptions.SenderClasses := esmNoSend). Etc. See also.

 

If you are not satisfied with run-time customization (as it will still add performance penalty at compilation and startup) - then you have to really compile your application without EurekaLog.

 

 

4. (Workaround) method #4: Disable "Catch memory leaks"

Often a reason behind having EurekaLog disabled is performance considerations. If this is a case - then you can use the following method: enable EurekaLog for your project, keep "Enable extended memory manager" option turned on, but turn off "Catch memory leaks" (and possible some other options on "Memory problems" page - but keep "Enable extended memory manager" turned on).

 

Long technical explanation

1. You get most performance hit from "Catch memory leaks" option, as EurekaLog has to build call stack for each memory allocation; while "Enable extended memory manager" option itself does not have major impact on performance.

2. It is strongly recommended to keep "Enable extended memory manager" option turned on when possible, as EurekaLog uses MM filter to track lifetime of exception objects. The worst case scenario would be: using Delphi 2007 or earlier, having "Enable extended memory manager" option turned off, having "Use low-level hooks" option turned off - EurekaLog won't be able to track lifetime of exception objects in such configuration.

 

 

See also:




Send feedback... Build date: 2023-09-11
Last edited: 2023-07-18
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/with_and_without.php