If you are linking your DAL invocations into an image, the VMS linker will automatically resolve a reference to GTM$INIT by including the GTM_MAIN module from the GTMLIB.OLB library. On the other hand, if your DAL calls are in an image that doesn't include GTM_MAIN and GTM$INIT and that cannot be relinked, you must create a separate shareable image to hold them. Such images typically use the lib$find image_symbol library routine to dynamically activate additional shareable images. All other DAL functions are already packaged in GTMSHR.EXE so this technique does not apply to them.
Example:
$ LINK/SHARE=GTMINIT.EXE GTM$DIST:GTMLIB/INCL=GTM_MAIN,SYS$INPUT/OPT Symbol_vector = (GTM$INIT = PROCEDURE)
The above example creates a shareable image named GTMINIT containing GTM$INIT. GTMINIT must be in SYS$LIBRARY or must be an executive mode logical name pointing to the location of GTMINIT.EXE.
Example:
#include descrip
getgtm()
{
$DESCRIPTOR(fil,"GTMINIT");
/* shareable image name for GTM$INIT */
$DESCRIPTOR(symb,"GTM$INIT");
/* symbol name in image GTM$INIT */
long (*init_addr)();
/* resulting pointer to call handle */
long status;
status = lib$find_image_symbol(&fil,&symb,&init_addr);
if ((status & 1) == 0)
return status;
status = (*init_addr)();
return status;
}
This C program uses the lib$find_image_symbol VMS system service to gain access to GTM$INIT.