Nonstop Database, HiRDB Version 9 UAP Development Guide
![[Contents]](FIGURE/CONTENT.GIF)
![[Index]](FIGURE/INDEX.GIF)
![[Back]](FIGURE/FRONT.GIF)
8.3.2 Compiling and linking in UNIX
You must use a compiler that conforms to the language used for the UAP in which the SQL statements are embedded to compile and link edit a post-source program created by the SQL preprocessor.
This section explains how to specify commands for compiling and linking in the UNIX environment, for each language.
- Organization of this subsection
- (1) C
- (2) COBOL
- (3) Note
Post-source programs in C must be compiled with a compiler that conforms to the ANSI C standards. Similarly, post-source programs in C++ must be compiled with a compiler that conforms to the C++ standards. The cc command (lowercase) is used to activate an ANSI C compiler, and the CC command (uppercase) is used to activate a C++ compiler. These commands can also be used to compile and link. This is the command format for activating a compiler:
cc [options] file-name directory distributed-library
- Note
- For C++, the underlined section must be changed to CC.
- file-name
- Specifies the name of the post-source file; the file identifier must be .c.
- directory
- Specifies the include directory (directory containing the header file of the library provided by HiRDB).
- distributed-library
- Specifies the library provided by HiRDB. Normally, a shared library should be used. An archive library should be used only to limit the version of the library used, or if a shared library cannot be used. If the UAP uses a thread, link a multi-connection library that corresponds to that thread.
- options
- Specifies the following options, as necessary:
- -o
- Specifies an optional name for the object file that is to be output; when this option is omitted, the filename is a.out.
- -I
- Specifies that an include directory is designated; compilation does not execute if this option is omitted.
- -Wl, +s
- Specifies that different HiRDB distribution library directories are used for UAP creation and for UAP execution. Specify this option if you use shared libraries with an HP-UX edition.
- When different distribution library directories are used for linkage and for execution, the SHLIB_PATH environment variable must be used at the time of execution to set the directory containing the distribution library.
(a) Examples of command specification in C
Examples of command specification in C are shown as follows. In these examples, the underlined text specifies the HiRDB installation directory.
- For UAPs that support the 32-bit mode
- Example 1: Shared library
- The post-source filename is sample and an executable form filename is not specified.
cc -I/HiRDB/include sample.c -L/HiRDB/client/lib -lzclt
|
- Example 2: Archive library
- The post-source filename is sample and the executable form filename is SAMPLE.
aCC +DD32 -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzclt
|
- Example 3: HP-UX (IPF)
aCC -Ae -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzclt
|
- Example 4: For multiple threads in HP-UX (IPF)
aCC -Ae -mt -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzcltk
|
- Example 5: Linux (EM64T)
gcc -m32 -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzclt
|
- Example 6: For multiple threads in Linux (EM64T)
gcc -m32 -D_REENTRANT -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzcltk
|
- For UAPs that support the 64-bit mode
- Example 1: Shared library
- The post-source filename is sample and an executable form filename is not specified.
- HP-UX 11.0
cc +DD64 -I/HiRDB/include sample.c -L/HiRDB/client/lib lzclt64
|
- HP-UX (IPF)
aCC -Ae +DD64 -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzclt64
|
- Multiple threads in HP-UX (IPF)
aCC -Ae -mt +DD64 -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzcltk64
|
- Solaris 8 and Solaris 9
cc -xarch=v9 -I/HiRDB/include sample.c -L/HiRDB/client/lib -lzclt64 -lnsl -lsocket
|
- AIX
xlc -q64 -I/HiRDB/include sample.c -Wl,-L/HiRDB/client/lib -lzclt64
|
- Linux (EM64T)
gcc -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzclt64
|
- Multiple threads in Linux (EM64T)
gcc -D_REENTRANT -I /HiRDB/include sample.c -L/HiRDB/client/lib -lzcltk64
|
- Note: Use libzcltk64.so even though the multi-connection facility is used by a single-threaded UAP.
- Example 2: Archive library
- The post-source filename is sample and an executable form filename is not specified.
- HP-UX 11.0
cc +DD64 -I/HiRDB/include sample.c /HiRDB/client/lib libclt64.a
|
- Solaris 8, and Solaris 9
cc -xarch=v9 -I/HiRDB/include sample.c -L/HiRDB/client/lib -lclt64 -lnsl -lsocket
|
- AIX
xlc -q64 -I/HiRDB/include sample.c -Wl,-L/HiRDB/client/lib -lclt64
|
(b) Examples of command specification in C++
Examples of command specification in C++ are shown as follows. In these examples, the underlined sections specify the HiRDB installation directory.
- For UAPs that support the 32-bit mode
- Example 1: Shared library
- The post-source filename is sample and an executable form filename is not specified.
CC -I/HiRDB/include sample.C -L/HiRDB/client/lib -lzclt
|
- Example 2: Archive library
- Post-source filename is sample and the executable form filename is SAMPLE.
CC -o SAMPLE -I/HiRDB/include sample.C /HiRDB/client/lib/libclt.a
|
- For UAPs that support the 64-bit mode
- Example 1: Shared library
- The post-source filename is sample and an executable form filename is not specified.
- HP-UX 11.0
CC +DA2.0w -I/HiRDB/include sample.C -L/HiRDB/client/lib lzclt64
|
- Solaris 8, and Solaris 9
CC -xarch=v9 -I/HiRDB/include sample.C -L/HiRDB/client/lib -lzclt64 -lnsl -lsocket
|
- AIX
xlc -q64 -I/HiRDB/include sample.C -Wl,-L/HiRDB/client/lib,-lzclt64
|
- Example 2: Archive library
- The post-source filename is sample and an executable form filename is not specified.
- HP-UX 11.0
CC +DA2.0w -I/HiRDB/include sample.C /HiRDB/client/lib libclt64.a
|
- Solaris 8, and Solaris 9
CC -xarch=v9 -I/HiRDB/include sample.C -L/HiRDB/client/lib -lclt64 -lnsl -lsocket
|
- AIX
xlc -q64 -I/HiRDB/include sample.C -Wl,-L/HiRDB/client/lib,-lclt64
|
Post-source programs in COBOL must be complied with the COBOL85, COBOL2002, MicroFocus COBOL, or SUN Japanese COBOL compiler. Post-source programs in OOCOBOL must be compiled with a compiler that conforms to the OOCOBOL standards.
The ccbl command is used to activate a COBOL85 compiler, and the ocbl command is used to activate an OOCOBOL compiler. These commands can also be used to compile and link. Following is the command format for activating a compiler:
ccbl [options] file-name directory distributed-library
- Note
- For OOCOBOL, the underlined section must be changed to ocbl.
- file-name
- Specifies the name of the post-source filename; the file identifier must be .cbl.
- directory
- Specifies the include directory (directory containing the header file of the library provided by HiRDB).
- distributed-library
- Specifies the COBOL library provided by HiRDB.
- options
- Specifies the following options, as necessary:
- -Wl, +s
- Specifies that different HiRDB distribution library directories is used for UAP creation and for UAP execution. Specify this option if you use shared libraries with an HP-UX edition.
- When different distribution library directories are used for linkage and for execution, the SHLIB_PATH environment variable must be used at the time of execution to set the directory containing the distribution library.
- -o
- Specifies an optional name for the object file that is to be output; when this option is omitted, the filename is a.out.
- The -Kl and -Xb options must not be specified; the -Xc option must not be specified together with the -Hf, -Hv, or -V3 option.
- environment-variable
- Specifies the following environment variable:
- CBLLIB
- Include directory.
(a) Examples of command specification in COBOL
Examples of command specification in COBOL are shown as follows. In these examples, the underlined sections specify the HiRDB installation directory. For the HP-UX (IPF) edition of COBOL2002, ccbl becomes ccbl2002.
- Example 1: Shared library
- The post-source filename is sample.
CBLLIB=/HiRDB/include
export CBLLIB
ccbl sample.cbl -L/HiRDB/client/lib -lzclt
|
- Example 2: Archive library
- The post-source filename is sample.
CBLLIB=/HiRDB/include
export CBLLIB
ccbl sample.cbl /HiRDB/client/lib/libclt.a
|
- Example 1: Shared library
- The post-source filename is sample.
CBLLIB=/HiRDB/include
export CBLLIB
ccbl2002 sample.cbl -L/HiRDB/client/lib -lzclt64
|
(b) Examples of command specification in OOCOBOL
Examples of command specification in OOCOBOL are shown as follows. In these examples, the underlined sections specify the HiRDB installation directory.
- Example 1: Shared library
- The post-source filename is sample.
CBLLIB=/HiRDB/include
export CBLLIB
ocbl sample.ocb -L/HiRDB/client/lib -lzclt
|
- Example 2: Archive library
- The post-source filename is sample.
CBLLIB=/HiRDB/include
export CBLLIB
ocbl sample.ocb /HiRDB/client/lib/libclt.a
|
When a UAP is created with the Solaris edition of HiRDB, that UAP cannot be connected to the HiRDB server when all of the following conditions are satisfied:
- The library that the HiRDB client uses is version 07-00-/C or later, and the library that the HiRDB server uses is earlier than 07-00-/C.
- The UAP and the HiRDB server to be connected are on the same machine.
In this case, use the client library (shared library) of the HiRDB server.
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.