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-2
Compiling SQL/MX Applications and Modules
Compiling SQL/MX Applications and Modules
NonStop SQL/MX Release 2.x provides two methods of compiling embedded SQL 
C/C++ programs and creating modules. Both methods create an identical module file. 
The first method described, using embedded module definitions, is the default and 
preferred method. 
The SQL/MX preprocessor reads a source file that contains C/C++ and embedded 
SQL statements and generates:
Compiling Embedded SQL C/C++ Programs With Embedded 
Module Definitions
Figure 15-1 on page 15-3 shows how a self-contained, single-file C/C++ program is 
compiled using embedded module definitions. The application’s embedded SQL 
source file is called sqlprog.sql.
Method 1: Embedded 
module definitions
One file: a single, self-contained annotated source file that 
contains source statements with SQL statements converted 
to comments and embedded module definitions. You compile 
this file (source-file.c in embedded SQL/MX C programs 
or source-file.cpp in embedded SQL/MX C++ 
programs) with the C/C++ compiler (c89) and the SQL/MX 
compiler (mxCompileUserModule). This is the default and 
preferred method.
Method 2: Annotated 
source file and 
module definition file
Two files: an annotated source file and a module definition 
file (source-file.m) that contains SQL source statements. 
You compile the source file with the C/C++ compiler, and you 
compile the module definition file with the SQL/MX compiler 
(mxcmp). A module definition file is not created unless you 
use the -x or -m preprocessor options or set the 
SQLMX_PREPROCESSOR_VERSION=800 environment 
variable to create a module definition file. For more 
information, see Influencing Module Management Behavior 
on page 17-7.










