Tuesday, April 1, 2014

Compiling C code with Informix 4GL

When I was assigned a task that involve integration work between MQ and 4GL, this was really exciting me because this will involve C programming language since C is my favorite language. But one thing to note is that this is not the regular C I’ve been doing in the pass. It is highly dependent on the version of Informix version I’m currently running.

As I ask around, the Informix environment we are running is called Rapid Development System, RDS for short. In this enviroment, there is a program that used to make the C code, named cfglgo.v2. It is not a compiler, rather it is a P-code (pseudocode) runner. My senior told me that there are also c4gl or i4gl, but these are not usable in ours environment. Following is the example on how this runner is call:

cfglgo.v2 -I/opt/mqm/inc fgiusr.c myrunner.c /opt/mqm/lib64/libmqic.so -o myrunner

Following output should be seen after the execution on the above statement:
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6
 /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/cc1 -quiet -v -I/usr/informix/incl/tools -I/usr/informix/incl/esql -I/opt/mqm/inc -D__arch64__ -D__sparcv9 fgiusr.c -mptr64 -mstack-bias -mno-v8plus -mcpu=v9 -quiet -dumpbase fgiusr.c -m64 -auxbase fgiusr -version -o /var/tmp//ccNzNEmS.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../../sparc-sun-solaris2.10/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/informix/incl/tools
 /usr/informix/incl/esql
 /opt/mqm/inc
 /usr/local/include
 /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/include
 /usr/include
End of search list.
GNU C version 3.4.6 (sparc-sun-solaris2.10)
        compiled by GNU C version 3.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 /usr/ccs/bin/as -V -Qy -s -xarch=v9 -o /var/tmp//cc4f9CWC.o /var/tmp//ccNzNEmS.s
/usr/ccs/bin/as: Sun Compiler Common 10 Patch 09/04/2007
 /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/cc1 -quiet -v -I/usr/informix/incl/tools -I/usr/informix/incl/esql -I/opt/mqm/inc -D__arch64__ -D__sparcv9 myprogram.c -mptr64 -mstack-bias -mno-v8plus -mcpu=v9 -quiet -dumpbase myprogram.c -m64 -auxbase mqfunc -version -o /var/tmp//ccNzNEmS.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../../sparc-sun-solaris2.10/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/informix/incl/tools
 /usr/informix/incl/esql
 /opt/mqm/inc
 /usr/local/include
 /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/include
 /usr/include
End of search list.
GNU C version 3.4.6 (sparc-sun-solaris2.10)
        compiled by GNU C version 3.3.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
 /usr/ccs/bin/as -V -Qy -s -xarch=v9 -o /var/tmp//ccv77fcB.o /var/tmp//ccNzNEmS.s
/usr/ccs/bin/as: Sun Compiler Common 10 Patch 09/04/2007
 /usr/local/libexec/gcc/sparc-sun-solaris2.10/3.4.6/collect2 -V -Y P,/usr/lib/sparcv9 -Qy -o fglmq /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crt1.o /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crti.o /usr/ccs/lib/sparcv9/values-Xa.o /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crtbegin.o -L/usr/informix/lib -L/usr/informix/lib/esql -L/usr/informix/lib/lib/tools -L/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9 -L/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6 -L/usr/ccs/bin/sparcv9 -L/usr/ccs/bin -L/usr/ccs/lib/sparcv9 -L/usr/ccs/lib -L/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../sparcv9 -L/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../.. -L/lib/sparcv9 -L/usr/lib/sparcv9 /var/tmp//cc4f9CWC.o /var/tmp//ccv77fcB.o /opt/mqm/lib64/libmqic.so /usr/informix/lib/tools/libfmain.a /usr/informix/lib/tools/libfglgo.a /usr/informix/lib/tools/lib4gl.a /usr/informix/lib/tools/lib4io.a /usr/informix/lib/tools/libnmenu.a /usr/informix/lib/tools/lib4io.a /usr/informix/lib/tools/librdsterm.a /usr/informix/lib/tools/libfmain.a /usr/informix/lib/tools/libfe.a /usr/informix/lib/tools/libfmain.a -ltermlib -liffgisql -lifasf -lifgen -lifos -lifgls -lnsl -lsocket -ldl -lm /usr/informix/lib/esql/checkapi.o -lifglx -laio -lm -ldl -lelf -ltermlib -lgcc -lgcc_eh -lc -lgcc -lgcc_eh -lc /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crtend.o /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/sparcv9/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.1518

The final output of this will generate a custom runner called myrunner. This runner will contain the required C implementation that is needed to execute a 4GL program. On 4GL site, the program must compile using fglpc in order to link with the runner. Assuming the the_4gl_program.4gl has successfully compile into the_4gl_program.4go, this would be the step to launch 4GL program:

myrunner the_4gl_program

No comments: