Windows CLI application compile and link options

The compile and link options in this topic are recommended by Db2® for building CLI applications with the Microsoft Visual C++ compiler. They are demonstrated in the sqllib\samples\cli\bldapp.bat batch file.

Compile options:

%BLDCOMP%
Variable for the compiler. The default is cl, the Microsoft Visual C++ compiler. It can be also set to icl, the Intel C++ Compiler for 32-bit and 64-bit applications, or ecl, the Intel C++ Compiler for Itanium 64-bit applications.
-Zi
Enable debugging information.
-Od
Disable optimizations. It is easier to use a debugger with optimization off.
-c
Perform compile only; no link.
-W2
Set warning level.
-DWIN32
Compiler option necessary for Windows operating systems.
-J
Compiler option that changes the default char type from signed char to unsigned char. The char type is zero-extended when widened to an int type. If a char type is explicitly declared as signed char then the –J option has no effect.

Link options:

link
Use the linker.
-debug
Include debugging information.
-out:%1.exe
Specify the executable.
%1.obj
Include the object file.
utilcli.obj
Include the utility object file for error checking.
db2api.lib
Link with the Db2 API library.
/delayload:db2app.dll
Used to ensure that db2app.dll is not loaded until the first call to a Db2 API. This is required when using the db2SelectDB2Copy API.
db2ApiInstall.lib
Library to statically link in your application if you need to select a particular Db2 copy that is installed on the computer using the db2SelectDB2Copy API. Note: to use this functionality, you need to either dynamically load db2app.dll or use the /delayload:db2app.dll option of your compiler and call the db2SelectDB2Copy API before running any other Db2 API's.

Refer to your compiler documentation for additional compiler options.