DB2 Version 10.1 for Linux, UNIX, and Windows

Linux C application compile and link options

The compile and link options for building C embedded SQL and DB2® API applications with the Linux C compiler are available in the bldapp build script.

Compile and link options for bldapp

Compile options:
$CC
The gcc or xlc_r compiler.
$EXTRA_C_FLAGS
Contains one of the following flags:
  • -m31 on Linux for zSeries only, to build a 32-bit library;
  • -m32 on Linux for x86, x64 and POWER®, to build a 32-bit library;
  • -m64 on Linux for zSeries, POWER, x64, to build a 64-bit library; or
  • No value on Linux for IA64, to build a 64-bit library.
-I$DB2PATH/include
Specify the location of the DB2 include files.
-c
Perform compile only; no link. This script file has separate compile and link steps.
Link options:
$CC
The gcc or xlc_r compiler; use the compiler as a front end for the linker.
$EXTRA_C_FLAGS
Contains one of the following flags:
  • -m31 on Linux for zSeries only, to build a 32-bit library;
  • -m32 on Linux for x86, x64 and POWER, to build a 32-bit library;
  • -m64 on Linux for zSeries, POWER, x64, to build a 64-bit library; or
  • No value on Linux for IA64, to build a 64-bit library.
-o $1
Specify the executable.
$1.o
Specify the object file.
utilemb.o
If an embedded SQL program, include the embedded SQL utility object file for error checking.
utilapi.o
If a non-embedded SQL program, include the DB2 API utility object file for error checking.
$EXTRA_LFLAG
For 32-bit it contains the value "-Wl,-rpath,$DB2PATH/lib32", and for 64-bit it contains the value "-Wl,-rpath,$DB2PATH/lib64".
-L$DB2PATH/$LIB
Specify the location of the DB2 static and shared libraries at link-time. For example, for 32-bit: $HOME/sqllib/lib32, and for 64-bit: $HOME/sqllib/lib64.
-ldb2
Link with the DB2 library.

Refer to your compiler documentation for additional compiler options.