The following sections provide detailed information about building applications for satellites that run Windows 32-bit operating systems.
The Visual C++ compiler is used for both C and C++ sample programs supplied in the %DB2PATH%\samples\c and %DB2PATH%\samples\cpp directories. The batch files in both these directories contain commands to accept either a C or C++ source file, depending on the file extension. By default, the C++ commands are commented out in the batch files in %DB2PATH%\samples\c, and the C commands are commented out in the batch files in %DB2PATH%\samples\cpp.
The batch file bldmsapi.bat, in %DB2PATH%\samples\c, and %DB2PATH%\samples\cpp, contains the commands to build a DB2 API program.
The parameter, %1, specifies the name of your source file.
@echo off rem bldmsapi.bat file rem Builds a DB2 API program in C or C++ rem using the Microsoft Visual C++ compiler. rem Usage: bldmsapi prog_name if "%1" == "" goto error rem Compile the C program. cl -Z7 -Od -c -W2 -D_X86_=1 -DWIN32 %1.c util.c rem For C++, comment out the above line, and uncomment the following: rem cl -Z7 -Od -c -W2 -D_X86_=1 -DWIN32 %1.cxx util.cxx rem Link the program. link -debug:full -debugtype:cv -out:%1.exe %1.obj util.obj db2api.lib goto exit :error echo Usage: bldmsapi prog_name :exit @echo on
Compile and Link Options for bldmsapi |
---|
The batch file contains the following compile options:
|
The batch file contains the following link options:
Refer to your compiler documentation for additional compiler
options.
|
To build the sample program, client, from either the source file client.c, in %DB2PATH%\samples\c, or from the source file client.cxx, in %DB2PATH%\samples\cpp, enter:
bldmsapi client
The result is an executable file, client.exe. You can run the executable file by entering the executable name (without the extension) on the command line:
client
The VisualAge C++ compiler is used for both C and C++ sample programs supplied in the %DB2PATH%\samples\c and %DB2PATH%\samples\cpp directories. The batch files in both these directories contain commands to accept either a C or C++ source file, depending on the file extension. By default, the C++ commands are commented out in the batch files in %DB2PATH%\samples\c, and the C commands are commented out in the batch files in %DB2PATH%\samples\cpp. This section demonstrates building programs using the C batch files.
The batch file bldvaapi.bat, in %DB2PATH%\samples\c, and in %DB2PATH%\samples\cpp, contains the commands to build a DB2 API program.
Ensure that the LIB environment variable points to %DB2PATH%\lib as follows:
set LIB=%DB2PATH%\lib;%LIB%
The parameter, %1, specifies the name of your source file.
@echo off rem bldvaapi.bat file rem Builds a DB2 API program using the IBM VisualAge C++ compiler. rem USAGE: bldvaapi <prog_name> rem Compile the program. icc -c -Ti -W1 %1.c util.c rem For C++, comment out the above line and uncomment the following: rem icc -c -Ti -W1 %1.c util.cxx rem Link the program. ilink /MAP /DEBUG /ST:32000 /PM:VIO %1.obj util.obj db2api.lib goto exit :error echo Usage: bldvaapi <prog_name> :exit @echo on
Compile and Link Options for bldvaapi |
---|
The batch file contains the following compile options:
|
The batch file contains the following link options:
Refer to your compiler documentation for additional compiler
options.
|
To build the sample program client from the C source file client.c, or the C++ file client.cxx, enter:
bldvaapi client
The result is an executable file client.exe. You can run the executable file against the SATCTLDB database by entering the executable name (without the extension):
client
The VisualAge C++ compiler differs from other compilers on Windows 32-bit operating systems. To compile a program with VisualAge C++ Version 4.0, you must first make a configuration file. For more information, refer to the documentation that is provided with the compiler.
DB2 provides configuration files for the different types of DB2 programs you can build with this VisualAge C++ compiler. To use a DB2 configuration file, first set an environment variable to the program name that you want to compile. Then compile the program with a command supplied by VisualAge C++ Version 4.0. The api.icc file is the DB2 API configuration file. See DB2 API Applications for information on how to use this file to compile your programs. For information about the other DB2 configuration files that are available, refer to the Application Building Guide.
The configuration file, api.icc, in %DB2PATH%\samples\c, allows you to build DB2 API programs in C. There is also a C++ DB2 API configuration file in %DB2PATH%\samples\cpp. These files can be used on AIX, OS/2 and Windows 32-bit operating systems.
// api.icc configuration file for DB2 API programs // for VisualAge C++ Version 4.0 // To use on AIX, enter: 'export API=prog_name' // To use on OS/2 and Windows, enter: 'set API=prog_name' // Then compile the program by entering: 'vacbld api.icc' if defined( $API ) { prog_name = $API } else { error "Environment Variable API is not defined." } infile = prog_name".c" util = "util.c" if defined( $__TOS_AIX__ ) { // Set db2path to where DB2 will be accessed. // The default is the standard instance path. db2path = $HOME"/sqllib" outfile = prog_name group lib = "libdb2.a" option opts = link( libsearchpath, db2path"/lib" ), incl( searchPath, db2path"/include" ) } else // if defined( $__TOS_OS2__ ) | defined( $__TOS_WIN__ ) { db2path = $DB2PATH outfile = prog_name".exe" group lib = "db2api.lib" option opts = link( libsearchpath, db2path"\\lib" ), incl( searchPath, db2path"\\include" ) } option opts { target type(exe) outfile { source infile source util source lib } }
VisualAge C++ Version 4.0 defines one of the following environment variables, depending on the operating system on which it is installed: __TOS_AIX__, __TOS_OS2__, __TOS_WIN__.
To use the configuration file to build the DB2 API sample program called client from the source file client.c, do the following:
set API=client
del api.ics
An existing api.ics file produced for the same program you are going to build again does not have to be deleted.
vacbld api.icc
Note: | The vacbld command is provided by VisualAge C++ Version 4.0. |
The result is an executable file, client. You can run the program by entering the executable name:
client
[ Top of Page ]