From: dafnioti@cae.wisc.edu (Petros Dafniotis)
Subject: VMS shareable images q.- Please help
Organization: U of Wisconsin-Madison College of Engineering
Distribution: comp.lang.fortran
Date: 26 Sep 92 10:45:31 CDT
Summary: Problem when using C rtl in a shareable and in exec. 

   We recently experienced a problem with our shareable images in the
VAX/VMS system. In my group we are writing applications for polymerization
reactors (using VAX FORTRAN); all of the low and middle level stuff is
organized in shareable images. A few months ago some of us added C
allocation/deallocation etc routines in the libraries of our package.
Creating shareable images for our libraries was still not a problem and
we were using the C rtl as a shareable when linking (i.e. the options
file for linking to produce a shareable was containing the line:
SYS$SHARE:VAXCRTL.EXE/SHARE
and everything was working fine... till I figured out that we cannot ship
our product to our sponsors since if they do not have the VAX C compiler
the references of our executables and shareables to the VAXCRTL.EXE will
crash the program. So we decided to use the library VAXCRTL.OLB instead.
Well,we did that and we got errors like the one in the example follows.
TO demonstrate the problem, I use
	test0.for              \  will be used together
	test1.c                /
	test2.c			- will become a shareable using test2.com

===========================================================================

test2.c
---------
#include <stdio.h>

void myprint(double *y)
{
   printf("\n\t\t This is: %g", *y);
   return;
}

test1.c
-------
#include <math.h>
#include <stdio.h>

void calc(double *x, double *y)
{
  *y = sqrt(*x);
  printf("\n\n\t Square-root calculation completed");
  return;
}

test0.for
---------
	program test0
	double precision x,y

	x = 10.0
	call calc(x, y)
	call myprint(y)
	end

==============================================================================

Now , I use the following test2.com procedure to generate the shareable:

test2.com
---------
$ cc/NoOpt test2.c
$ link/nodebug/shareable=test2.exe -
   test2.obj, -
   sys$library:vaxcrtl.olb/library, -
   sys$input/option
UNIVERSAL = myprint
$ exit

and with
@TEST2.COM
voila I have the test2.exe shareable image. Ok, I use the test0.com to
build the final executable:

test0.com
---------
$ fortran test0.for
$ cc/NoOptimize test1.c
$ link/exec=test0.exe -
     test0.obj, test1.obj, sys$library:vaxcrtl.olb/library, -
     sys$input/option
dsk$user:[dafniotis.fortran.scratch]test2.exe/share
$ exit

and using
@TEST0.COM

I get the error:
%LINK-E-OUTSIMG, attempted store location %X0000A024 is outside image binary
(%X00000000 to %X00000000)
     in psect STDIN module C$VAXCIO file SYS$COMMON:[SYSLIB]VAXCRTL.OLB


As you might have guessed the %X0000A024 appears in the map of the TEST2
shareable image (test2.exe) for the psect STDIN. I have tried several
solutions (using CLUSTER, declaring STDIN with LCL attribute etc) to no
effect. Of course the easy solution would be to let out of the TEST0.COM
the reference to the C RTL library, finding out the references the linker
did not resolve (from the C RTL), then going to the TEST2.COM and force
the linker to include the necessary modules from the VAXCRTL.OLB and declare
the unresolved references as UNIVERSAL for the TEST2.EXE. Indeed this worked,
but it is MESSY!

  PLEASE HELP! What am I doing wrong?

						Petros Dafniotis
						Chem Engr Dept, UW-Madison
				e-mail: dafniotis@chera6.che.wisc.edu
					dafnioti@cae.wisc.edu


PS: Details for our system:
	VAXstation 4000
	VAX/VMS v5.5
	VAX FORTRAN v5.7-133
	VAX C v 3.2-044


+--------------------------------------------------------------------------+
| E-mail:  dafniotis@chera1.che.wisc.edu  | Petros Dafniotis               |
|          dafniotis@che31a.che.wisc.edu  | Chem Engr Dept                 |
|           dafnioti@cae.wisc.edu         | University Of Wisconsin-Madison|
+--------------------------------------------------------------------------+
|                            VAX + VMS  4  EVER!                           |
+--------------------------------------------------------------------------+

Newsgroups: comp.lang.fortran