SQL/MX Programming Manual for C and COBOL (H06.10+, J06.03+)
C/C++ Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—544617-003
15-50
Building and Deploying a C Application With
Embedded Module Definitions and Module Definition
3. Run the C/C++ compiler to compile the annotated source files into object files:
c89 -Wversion2 -I /usr/tandem/sqlmx/include -c sqlprog1.cpp
c89 -Wversion2 -I /usr/tandem/sqlmx/include -c sqlprog2.cpp
4. Run the native linker to build a self-contained OSS executable file named
sqlprog.
•
For TNS/E native applications, use the eld utility:
eld -verbose /usr/lib/ccplmain.o sqlprog1.o sqlprog2.o \
sqlprog.exe -lzcppcdll -lzcpp2dll -lzcredll -lzcrtldll \
-lzosskdll -lzi18ndll -lzicnvdll -lzclidll -lztlh7dll
•
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










