OpenTP1 Version 7 User's Guide

[Contents][Index][Back][Next]

3.2.1 Creating UAPs in C language

This subsection explains UAP creation in C language.

Organization of this subsection
(1) Preparing a manifest file
(2) Installing C runtime libraries
(3) Example of a makefile (C language: SPP)
(4) Example of a makefile (C language: MHP)

(1) Preparing a manifest file

You need a manifest file in order to run a program created in Visual Studio. Either embed the manifest file in the program or copy the manifest file to the folder where the executable file is located.

Reference note
A manifest file contains information about the libraries (DLLs) that are required in order to run executable files (such as .exe and .dll). A manifest file is created automatically when an executable file is created. This is a mandatory file for running an executable file.

(2) Installing C runtime libraries

Because TP1/Server Base has been created by Visual Studio, you must install C runtime libraries to run TP1/Server Base.

For details about the C runtime libraries that must be installed, see the Release Notes.

(3) Example of a makefile (C language: SPP)

This subsection shows an example of a makefile needed for creating an SPP.

(a) Names of source files

The following shows the names of the source files that are used in the example of a makefile.

(b) Example of a makefile

The following shows an example of a makefile:

NODEBUG = 1
!include <ntwin32.mak>
# TP1TEST Make File
SYSLIB = $(conlibsdll)
TP1LIB = [libdam.lib]#1 [libtam.lib]#2 libbetran.lib
 
all:TP1TEST.exe
# Compile
exmain.obj:exmain.c
         $(cc) $(cflags) $(cvarsdll) $*.c
exsv1.obj:exsv1.c
         $(cc) $(cflags) $(cvarsdll) $*.c
exsv2.obj:exsv2.c
         $(cc) $(cflags) $(cvarsdll) $*.c
ex_sstb.obj:ex_sstb.c
         $(cc) $(cflags) $(cvarsdll) $*.c
# Create a stub source file
ex_sstb.c:ex.def
         $(DCDIR)\bin\stbmake $?
# Link
TP1TEST.exe: exmain.obj exsv1.obj exsv2.obj ex_sstb.obj
         $(link) $(conflags) -out:$*.exe $** \
         [$(DCDIR)\spool\trnrmcmd\userobj\dctrninf.obj \]#3
         $(TP1LIB) $(SYSLIB)
         [mt -manifest $@.manifest -outputresource:$@;1]#4

#1
Specify libdam.lib only if you use TP1/FS/Direct Access.

#2
Specify libtam.lib only if you use TP1/FS/Table Access.

#3
Specify $(DCDIR)\spool\trnrmcmd\userobj\dctrninf.obj only if you use the transaction facility. For dctrninf.obj, specify the name of the object file for transaction control that was created by the trnmkobj command. For details about the trnmkobj command, see Chapter 7. Operation Commands.

#4
Delete this row if you do not embed the manifest file.

(4) Example of a makefile (C language: MHP)

This subsection shows an example of a makefile needed for creating an MHP.

NODEBUG = 1
!include <ntwin32.mak>
# makefile for making UAP(C Language)
 
# command
STBMAKE           =       $(DCDIR)\bin\stbmake.exe
 
# stub name
STBMAKE_MHP_SRC   =       mhp_sstb
 
# user server object
MHP_SRC           =       mhpmain.obj mhp_sv.obj
 
# include file
INCDIR            =       -I.                 \
                          -I $(DCDIR)\include
 
# common object
SH_OBJ            =       $(DCDIR)\spool\trnrmcmd\userobj\mcf_sw.obj
 
# common library
LIBNAME           =       $(DCDIR)\lib\libmcf.lib \
                          $(DCDIR)\lib\libmnet.lib \
                          $(DCDIR)\lib\libbetran.lib
 
# compiler options
CC                =       $(cc)
CCOPT             =       -nologo $(cflags) $(cvarsdll)
CONFIG            =       -c
CFLAGS            =       $(CCOPT) $(CONFIG) $(INCDIR)
 
# linker options
LK                =       $(link)
LNKFLG            =       $(conflags) /NODEFAULTLIB
LINKAGE           =       $(conlibsdll) $(LIBNAME) msvcrt.lib
 
.c.obj:
       $(CC) $*.c $(CFLAGS)
 
all : $(SH_OBJ) tcpmhp.exe
 
$(STBMAKE_MHP_SRC).c :
        $(STBMAKE) -s $(STBMAKE_MHP_SRC).c $(STBMAKE_MHP_SRC).def
 
tcpmhp.exe : $(STBMAKE_MHP_SRC).obj $(MHP_SRC)
        $(LK) $(LNKFLG) $** $(LINKAGE) $(SH_OBJ) -out:$@
        !if exist $@.manifest mt.exe -nologo -manifest $@.manifest -outputresource:$@;1
        !if exist $@.manifest del $@.manifest
 
$(SH_OBJ) :
        $(DCDIR)\bin\trnmkobj -o mcf_sw -R OpenTP1_MCF