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 COBOL—523627-004
15-46
Building and Deploying a C Application With
Embedded Module Definitions and Module Definition
4. 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
5. 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 module definitions. It does not overwrite
the Windows-developed sqlprog’s modules because they use the module name
prefix ‘FINANCE.WINDEV’. Assuming that the object ‘sqlprog’ coming from
Windows is at a different location than the one compiled and linked on OSS (for
example, /home/fin/windev/sqlprog and /home/fin/ossdev/sqlprog
respectively), you can now run, test, and debug both the Windows-developed
sqlprog and the OSS-developed sqlprog simultaneously on \pecan without
module confusion, interference, or accidental overwrites.
Building and Deploying a C Application With Embedded Module
Definitions and Module Definition Files
Suppose that you have a set of SQL utility routines that were developed using SQL/MX
Release 1.8. The object code is in sqlutil.o. Use these steps to build, statically link
in sqlutil.o, and deploy a new application sqlapp.exe in the OSS environment.
1. Create C or C++ source files (for example, sqlapp.sql) that contain embedded
SQL/MX statements:
// sqlapp.sql
EXEC SQL DECLARE SCHEMA 'cat.sch';
EXEC SQL MODULE sqlappmod; // might be externally qualified
at SQL preprocess-time
EXEC SQL DECLARE CURSOR m FOR SELECT * FROM =midcaps;
int main() { ...
}
2. Run the SQL/MX C/C++ preprocessor:
mxsqlc sqlapp.sql -c sqlapp.cpp
This command creates an annotated source file (sqlapp.cpp) that contains the
SQL/MX CLI call translations of the embedded SQL statements and an extra
C/C++ source construct that represents its module definition.










