SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

C/C++ Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
15-44
Developing a Native C/C++ Program With
Embedded SQL/MX Statements on OSS
mxsqlc sqlprog1.sql -c sqlprog1.cpp -s pecan \
-y finance.tomr -z abc123 \
-g moduleCatalog=FINANCE -g moduleSchema=WINDEV
mxsqlc sqlprog2.sql -c sqlprog2.cpp -s pecan \
-y finance.tomr -z abc123 \
-g moduleCatalog=FINANCE -g moduleSchema=WINDEV
These commands create two annotated source files (sqlprog1.cpp and
sqlprog2.cpp) that contain the SQL/MX CLI call translations of the embedded
SQL statements and extra C/C++ source constructs that represent the module
definitions. These generated files will have hard-coded references to the modules
named FINANCE.WINDEV.sqlprog1mod and
FINANCE.WINDEV.sqlprog2mod. For security reasons, these module
references cannot be remapped at run time.
3. Run the C/C++ compiler to compile the annotated source files into object files.
Suppose that the SQL/MX CLI and other HP header files are in the "../include"
directory.
c89 -Wversion2 -Wsqlmx -Wmxcmp -Wverbose -I/usr/include \
-c sqlprog1.ecpp sqlprog2.ecpp -o sqlprog
4. Transfer the object files (sqlprog1.o and sqlprog2.o) to the NonStop system
(for example, \pecan).
5. Run the native linker to build a self-contained OSS executable file named
sqlprog. For TNS/R native applications, use the nld utility:
nld -elf -set systype oss -set highpin off -set \
highrequestor on -set inspect on -obey \
/usr/lib/libc.obey -set saveabend on \
/usr/lib/crtlmain.o sqlprog1.o sqlprog2.o \
-l zcplsrl -l zcrtlsrl -l zcresrl -l zcplosrl -l ztlhgsrl \
-l ztlhosrl -Bdynamic -l zclisrl -o sqlprog
6. Set up needed DEFINEs and run the SQL/MX compiler:
add_define =stocks \
class=map file=\\pecan.\$finance.assets.adrs
add_define =bonds \
class=map file=\\pecan.\$finance.assets.munis
mxCompileUserModule -v -d AUTOMATIC_RECOMPILATION=ON \
-d RECOMPILATION_WARNINGS=ON -d SIMILARITY_CHECK=ON \
sqlprog
This command compiles the application’s modules. The application (sqlprog) is
now runnable on \pecan.
Developing a Native C/C++ Program With Embedded SQL/MX
Statements on OSS
This example illustrates how to use OSS tools to build a C or C++ program that has
two or more source files containing embedded SQL/MX statements into a self-