- c程序
$ cat main.c
#include <stdio.h>
#include <string.h>
#include "cobmain.h"
#include "cobcall.h"
#include "cblproto.h"
int main(int argc, char *argv[])
{
printf("entry of main\n");
cobinit(); /* Initialize COBOL environment */
cobcall("HELLOWORLD", 0, NULL); /* Call a COBOL program */
cobtidy(); /* Close down COBOL environment */
return(0);
}
- cobol程序
$ cat HELLOWORLD.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
BEGIN-PGM.
DISPLAY "HELLO WORLD!".
STOP RUN.
- makefile
$ cat makefile.main
COBDIR=/opt/microfocus/cobol5.1
DB2DIR=/opt/ibm/db2/V9.7
all: HELLOWORLD.gnt main
.SUFFIXES: .cbl .gnt
.cbl.gnt:
cob -ug $*.cbl -C "use(opt.dir)" -C "list($*.lst)" -C XREF -C SETTINGS
main: main.c
gcc -o $@ -I${COBDIR}/include -L${COBDIR}/lib -lcobrts64 -lcobcrtn64 -lcobmisc64 -lcobscreen64 -ldl $<
clean:
-rm -rf c *.lst *.lis *.int *.idy *.so *.gnt *.o *.bnd core.* main
- 编译运行
$ make
$ ./main
entry of main
HELLO WORLD!
网友评论