Building CLI applications on UNIX
Db2® provides build
scripts for compiling and linking CLI programs. These are
located in the sqllib/samples/cli directory, along with sample programs that
can be built with these files.
The script file bldapp contains the
commands to build a CLI application. It takes
up to four parameters, represented inside the script file by the variables
$1
,
$2
, $3
, and $4
. The parameter,
$1
, specifies the name of your source file. This is the only required parameter,
and the only one needed for CLI applications that do
not contain embedded SQL. Building embedded SQL programs requires a connection to the database so
three optional parameters are also provided: the second parameter, $2
, specifies
the name of the database to which you want to connect; the third parameter, $3
,
specifies the user ID for the database, and $4
specifies the password. If the
program contains embedded SQL, indicated by the .sqc
extension, then the
embprep
script is called to precompile the program, producing a program file with a
.c
extension.About this task
tbinfo
from the source
file tbinfo.c
, enter: bldapp tbinfo
The result is an executable file, tbinfo
. You can
run the executable file by entering the executable name: tbinfo