Linux C routine compile and link options

The compile and link options for building C routines, such as stored procedures and user-defined functions, with the Linux® C compiler are available in the bldrtn build script.

Compile and link options for bldrtn

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.
-D_REENTRANT
Defines _REENTRANT, needed as the routines can run in the same process as other routines (THREADSAFE) or in the engine itself (NOT FENCED).
Link options:
$CC
The gcc or xlc_r compiler; use the compiler as a front end for the linker.
$LINK_FLAGS
Contains the value "$EXTRA_C_FLAGS $SHARED_LIB_FLAG"
$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.
$SHARED_LIB_FLAG
Contains -shared for gcc compiler or -qmkshrobj for xlc_r compiler.
-o $1
Specify the executable.
$1.o
Include the program object file.
$EXTRA_LFLAG
Specify the location of the Db2 shared libraries at run-time. For 32-bit it contains the value "-Wl,-rpath,$DB2PATH/lib32". 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.
-lpthread
Link with the POSIX thread library.

Refer to your compiler documentation for additional compiler options.