Linux CLI application compile and link options
The compile and link options in this topic are recommended by Db2® for building CLI applications with the
GNU/Linux gcc compiler. They are demonstrated in the sqllib/samples/cli/bldapp
build script.
Compile options:
gcc
- The C compiler.
$EXTRA_C_FLAGS
- Consists of one of the listed 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. For
example:
$HOME/sqllib/include
-c
- Perform compile only; no link. Compile and link are separate steps.
Link options:
gcc
- Use the compiler as a front end for the linker.
$EXTRA_C_FLAGS
- Consists of one of the listed 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
- Include the program object file.
utilcli.o
- Include the 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.