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:
g++
The GNU/Linux C++ 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.
-fpic
Generate position independent code.
-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:
g++
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.
-shared
Generate a shared library.
-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.