  Problems with Linker Documentation? 
 The Question is:
 
Hello,
 
I tried your example in OpenVMS Linker Utility, but got some errors. Please
 advise on how to use the VMS linker to add symbol vector.  Thanks.
 
my_math.cxx
 
int myadd(int value_1, int value_2)
 
   int result;
   result=value_1 + value_2;
   return(result);
 
 
int mysub(int value_1, int value_2)
 
   int result;
   result=value_1 - value_2;
   return(result);
 
 
$ cxx my_math.cxx
$ link /share my_math.OBJ, -
                sys$input:/opt
        SYMBOL_VECTOR=(myadd=procedure,mysub=procedure)
 
Here is what I get:
 
%LINK-W-NUDFSYMS, 2 undefined symbols:
%LINK-I-UDFSYM,         MYADD
%LINK-I-UDFSYM,         MYSUB
%LINK-W-USEUNDEFSYMV, undefined symbol MYADD referenced
        in symbol vector option
%LINK-W-USEUNDEFSYMV, undefined symbol MYSUB referenced
        in symbol vector option
 
 
 
 
 
 
 The Answer is:
 
  Thank you for bringing this old VAX C syntax to the attention
  of the OpenVMS Wizard.  (Please note that the examples are C,
  and not C++.)
 
  Please see the shareable image cookbook available at the Ask
  The Wizard website, and also please see topic 2486.
 
  An updated version -- one that contains the rough equivilent of
  the various examples present in chapters 2, 3, and 4 of the
  OpenVMS LINKER manual -- is included below.
 
 
 
 
$! my_linker_demo.com
 
$! OpenVMS LINKER Example Procedure
 
$ CALL CLEAN
 
$ create my_defs.h
#ifndef __MY_LOADED
#define __MY_LOADED 1
int myadd( int, int );
int mysub( int, int );
int mymul( int, int );
int mydiv( int, int );
#endif
 
$ create my_main.c
#include "my_defs.h"
#include &lt;stdio.h&gt;
#include &lt;ssdef.h&gt;
main()
  {
  int Num1 = 6, Num2 = 5, Result = 0;
 
  Result = mysub( Num1, Num2 );
  printf("The result is %d\n", Result );
 
  return SS$_NORMAL;
  }
 
$ cc/decc/prefix=all my_main.c
 
$ create my_math.c
#include "my_defs.h"
myadd( int Val1, int Val2 )
  {
  return Val1 + Val2;
  }
mysub( int Val1, int Val2 )
  {
  return Val1 - Val2;
  }
mymul( int Val1, int Val2 )
  {
  return Val1 * Val2;
  }
mydiv( int Val1, int Val2 )
  {
  return Val1 / Val2;
  }
 
$ cc/decc/prefix=all my_math.c
 
 
$! +++++++
$! MY_IMG1 -- Create a monolithic image
$!
$ link/execute=my_img1 my_math.obj,my_main.obj
 
$! Run the MY_IMG1 image.
$!
$ write sys$output "run my_img1"
$ run my_img1
 
 
$! +++++++
$! MY_IMG2 -- With an object library
$!
$ library/create/object/insert my_objlib.olb my_math.obj
$ link/execute=my_img2 my_main.obj,my_objlib/library
 
$! Run the MY_IMG2 image.
$!
$ write sys$output "run my_img2"
$ run my_img2
 
 
$! +++++++
$! MY_IMG3 -- With a (temporary/user) library reference via LNK$LIBRARY
$!
$ define/user lnk$library my_objlib.olb
$ link/execute=my_img3.exe my_main.obj
 
$! Run the MY_IMG3 image.
$!
$ write sys$output "run my_img3"
$ run my_img3
 
$ goto SHRIMG_'f$getsyi("ARCH_NAME")
$ exit
 
 
$SHRIMG_VAX:
 
$! Build an OpenVMS VAX shareable image.
 
$! Build the Macro32 transfer vectors.
$!
$ macro sys$input:/object=my_vectors.obj
 
; create a program section to hold just the vectors, and
; to keep all transfer vectors quadword aligned.
 
    .psect  $$$XFRVEC,exe,shr,nowrt,rd,pic,quad
 
; define a macro to simplify creating a transfer vector
; to a routine located in the shareable image.
 
    .macro  XFRVEC  entry_point
    .align  QUAD
    .transfer       entry_point
    .mask   entry_point
    JMP             l^entry_point+2
    .endm
 
; define a macro that places a longword constant directly
; into the transfer vector array.
 
    .macro  XFRCON  constant
    .align  QUAD
    .long   constant
    .endm
 
; and start defining the transfer vectors...
; Append any new entries, and do not remove any existing entries
; (Either make all changes to the vectors in an upward-compatible
; fashion, or plan to have to change the GSMATCH major value on
; the shareable image.)
 
    XFRVEC  myadd
    XFRVEC  mysub
    XFRVEC  mymul
    XFRVEC  mydiv
 
    .End
 
 
$! +++++++++
$! MY_SHRIMG -- Link a shareable image on an OpenVMS VAX system
$!
$ link/shareable=my_shrimg my_math.obj,my_vectors.obj,sys$input:/option
gsmatch=lequal,1,42
Cluster=$$$XFRVEC
Collect=$$$XFRVEC,$$$XFRVEC
 
$ Goto SHRIMG_COMMON
 
$SHRIMG_Alpha:
 
$! Build an OpenVMS VAX shareable image.
 
$! +++++++++
$! MY_SHRIMG -- Link a shareable image on an OpenVMS Alpha system
$!
$ link/shareable=my_shrimg my_math.obj,sys$input:/option
gsmatch=lequal,1,42
! do not re-order nor remove any symbol vector entries.
! append all new entries to the end of the list.
SYMBOL_VECTOR=(-
    myadd=PROCEDURE,-
    mysub=PROCEDURE,-
    mymul=PROCEDURE,-
    mydiv=PROCEDURE )
 
$ Goto SHRIMG_COMMON
 
$SHRIMG_COMMON:
 
 
$! +++++++
$! MY_IMG4 -- Link with the shareable image
$!
$ link/execute=my_img4 my_main.obj,sys$input/options
my_shrimg/shareable
 
$! Run the MY_IMG4 image.
$!   Since the shareable image is not in SYS$SHARE:, we
$!   need a (temporary/user) logical name to reference it.
$!
$ write sys$output "run my_img4"
$ define/user my_shrimg sys$disk:[]my_shrimg
$ run my_img4
 
 
$! +++++++
$! MY_IMG5 -- Link with the shareable image via a shareable image library
$!
$ library/create/share/insert my_shrlib.olb my_shrimg.exe
$ define/user lnk$library my_shrlib.olb
$ link/execute=my_img5 my_main.obj
 
$! Run the MY_IMG5 image.
$!   Since the shareable image is not in SYS$SHARE:, we
$!   need a (temporary/user) logical name to reference it.
$!
$ write sys$output "run my_img5"
$ define/user my_shrimg sys$disk:[]my_shrimg
$ run my_img5
 
$ CALL CLEAN
 
$ EXIT
 
$CLEAN: SUBROUTINE
 
$! Clean up any remnants
 
$ if f$search("my_defs.h") .nes. "" then delete my_defs.h;*
$ if f$search("my_main.c") .nes. "" then delete my_main.c;*
$ if f$search("my_main.obj") .nes. "" then delete my_main.obj;*
$ if f$search("my_math.c") .nes. "" then delete my_math.c;*
$ if f$search("my_math.obj") .nes. "" then delete my_math.obj;*
$ if f$search("my_img1.exe") .nes. "" then delete my_img1.exe;*
$ if f$search("my_img2.exe") .nes. "" then delete my_img2.exe;*
$ if f$search("my_img3.exe") .nes. "" then delete my_img3.exe;*
$ if f$search("my_img4.exe") .nes. "" then delete my_img4.exe;*
$ if f$search("my_img5.exe") .nes. "" then delete my_img5.exe;*
$ if f$search("my_vectors.obj") .nes. "" then delete my_vectors.obj;*
$ if f$search("my_shrimg.exe") .nes. "" then delete my_shrimg.exe;*
$ if f$search("my_shrlib.olb") .nes. "" then delete my_shrlib.olb;*
$ if f$search("my_objlib.olb") .nes. "" then delete my_objlib.olb;*
 
$ ENDSUBROUTINE
 
 
