IBM Books

Building Applications for UNIX** Environments


Coding a Script File by Platform

The script file clibld contains the commands to build the sample DB2 CLI program clisampl.c. You can find both the script file and clisampl.c in sqllib/samples/cli.

Study the script file and the compiler options for the platform you are using. Then go to "Building and Running a CLI Program" for the steps to follow in order to build and run the program.

AIX

IBM XL C is used in the following version of the clibld script file:




#! /bin/ksh
# clibld script file -- AIX
# Build clisampl
 
# Compile the program.
xlc -I/usr/lpp/db2_05_00/include -c clisampl.c
 
# Link the program.
xlc -o clisampl clisampl.o -L/usr/lpp/db2_05_00/lib -ldb2


Compile and Link Options for clibld

The script file contains the following compile options:

xlc
The IBM XL C compiler.

-Ipath
Specify the location of the DB2 include files. For example: -I/usr/lpp/db2_05_00/include

-c
Perform compile only; no link. This book assumes that compile and link are separate steps.

The script file contains the following link options:

xlc
Use the compiler to link edit.

-o filename
Specify the name of the executable program.

-ldb2
Link with the database manager library.

-Lpath
Specify the location of the DB2 runtime shared libraries. For example: -L/usr/lpp/db2_05_00/lib. If you do not specify the -L option, the compiler assumes the following path: /usr/lib:/lib.

Refer to your compiler documentation for additional compiler options.

Note:Multi-threaded applications on AIX Version 4 need to be compiled and linked with the xlc_r compiler instead of the xlc compiler, or with the xlC_r compiler instead of the xlC compiler.

HP-UX

HP-UX C is used in the following version of the clibld script file:




#! /bin/ksh
# clibld script file -- HP-UX
# Build clisampl
 
# Compile the program.
cc -Aa +e -I/opt/IBMdb2/v5.0/include -c clisampl.c
 
# Link the program.
cc -o clisampl clisampl.o -L/opt/IBMdb2/v5.0/lib -ldb2 -lhppa


Compile and Link Options for clibld

The script file contains the following compile options:

cc
Use the C compiler.

-Aa
Use ANSI standard mode.

+e
Enables HP value-added features while compiling in ANSI C mode.

-Ipath
Specify the location of the DB2 include files. For example: -I/usr/IBMdb2/v5.0/include

-c
Perform compile only; no link. This book assumes that compile and link are separate steps.

The script file contains the following link options:

cc
Use the compiler to link edit.

-o filename
Specify the name of the executable program.

-Lpath
Specify the location of the DB2 runtime shared libraries.

-ldb2
Link with the database manager library.

-lhppa
Specify the HP PA-RISC library (required).

Refer to your compiler documentation for additional compiler options.

Note:Multi-threaded applications on HP-UX need to be linked with libcma.sl. Add -lcma to the end of the link command when building a multi-threaded application.

Solaris

SPARCompiler C is used in the following version of the clibld script file:




#! /bin/ksh
# clibld script file -- Solaris
# Build clisampl
 
# Compile the program.
cc -I/opt/IBMdb2/v5.0/include -c clisampl.c
 
# Link the program.
cc -o clisampl clisampl.o -L/opt/IBMdb2/v5.0/lib -R/opt/IBMdb2/v5.0/lib -ldb2


Compile and Link Options for clibld

The script file contains the following compile options:

cc
Use the C compiler.

-Ipath
Specify the location of the DB2 include files. For example: -I/usr/IBMdb2/v5.0/include

-c
Perform compile only; no link. This book assumes that compile and link are separate steps.

The script file contains the following link options:

cc
Use the compiler to link edit.

-o filename
Specify the name of the executable program.

-Lpath
Specify the location of the DB2 static and shared libraries at link-time.

-Rpath
Specify the location of the DB2 shared libraries at run-time.

-ldb2
Link with the DB2 library.

Refer to your compiler documentation for additional compiler options.

Note:Multi-threaded applications on Solaris need to be compiled with the -D_REENTRANT flag, and linked with libthread.so. Add -D_REENTRANT following the cc or xlc compile command, and add -lthread to the end of the link command, when building a multi-threaded application.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]