Setting up your C project and including the API in your modules

 

Setting up your project

As ITLogLib/Win32 uses a runtime DLL, you must link your projects to ITLogLib2Win32.dll. This is usually done linking to a so-called import library for the DLL. Import libraries are compiler / linker dependent (see below).

 

Therefore do this to setup your project:

1.    Check out if iTech Logging already ships with an import library for your C compiler.

The import libraries can be found in subdirectories of the directory .\ITLogLib\Win32\lib of your ITL installation.

Note:

If you have a C++ (instead of C-only) project and compiler, you should use ITLogLib/Standard C++ or ITLogLib/Visual C++ instead of ITLogLib/Win32, although you might find ITLogLib/Win32 import libraries for your compiler/linker in the directory mentioned above. In this case please don't look here but read the online help for ITLogLib/Standard C++ or ITLogLib/Visual C++!

 

2.    If not, create an import library file for ITLogLib2Win32.dll.

 

The procedure how to create DLL import libraries for your development environment should be described in its online help or its other documentation.


Examples:

Borland C++ products
(C++ and C++ Builder)

use IMPLIB.EXE to create ITLogLib2Win32.lib

GNU C++ compiler (g++)

use DLLTOOL.EXE to create ITLogLib2Win32.a

 

3.    Add the import library file to your project.

 

The exact procedure here again depends on your development environment and should be documented there.

 

 

Including the API in your modules

 

To include the logging API in your C modules (*.c files), just add the following line at the top:

 

#include <ITLogLib2Win32.h>

 

Note:

Especially for larger projects we recommend to include the header file "ITLogLib2Win32" in another commonly used project-specific header file which is already included in every C module. If you don't have such a header file already you probably should create one.

This indirect inclusion of "ITLogLib2Win32" using another header file is essentially a wrapping technique and has the following additional advantages:

·      You can add logging related utilities to "ITLogLib2Win32.h" using the wrapper header file.

·      It would be easy to switch your project to a new version of ITLogLib/Win32 ("#include ITLogLib3Win32.h").

·      If your compiler supports that, the wrapper header file -- if it contains all the header files you normally need -- would be a good candidate to be designated by you as a header file which should be used in precompiled form (for faster compilation).