1822503 Members
2392 Online
109642 Solutions
New Discussion юеВ

Shareable image

 
Deepak kumar_3
Frequent Advisor

Shareable image

Hi,

How to create C++ shareable images on
OpenVMS Alpha.

-Deepak
13 REPLIES 13
Hein van den Heuvel
Honored Contributor

Re: Shareable image

Uh... LINK/SHARE ?

Check Language USerguide
http://h71000.www7.hp.com/commercial/cplus/alpha_doc/

Compaq C++
Using Compaq C++ for OpenVMS Alpha

http://h71000.www7.hp.com/commercial/cplus/alpha_doc/ugvhdr.html#index_x_299

3.5 Sample Code for Creating OpenVMS Shareable Images

Also check the LINKER reference manual.

If you have SPECIFIC questions/problems, then I'm sure we'll be able to help more.

Regards,
Hein.
Kris Clippeleyr
Honored Contributor

Re: Shareable image

Hi,

Although I'm not familiar with creating shareable images from modules written in C++, I guess it isn't that much different than for instance from modules written in C.

Please have a look at the OpenVMS Linker Utility Manual, Chapter 4, Creating Shareable Images.

Greetz,

Kris
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Antoniov.
Honored Contributor

Re: Shareable image

Hi Deepak,
shareabel images are different from VAX VMS.
On alpha you don't need macro file with shareable entry points. You need declare your entry points and public variables using link; to make this you have to create e .OPT file like follows:
GSMATCH=LEQUAL,1,100
SYMBOL_VECTOR = ( -
ENTRYA = PROCEDURE, -
ENTRYB = PROCEDURE, -
)
PSECT_ATTR=MY_PUBLIC_VAR,NOSHR
PSECT_ATTR=MY_RO_TABLE,SHR,NOWRT
where
ENTRYA, ENTRYB may be your entry points for your C/C++ functions;
MY_PUBLIC may be a public variable, no shareable;
my_RO_TABLE may be a read-only public variable;

HTH
Antonio Vigliotti
Antonio Maria Vigliotti
Willem Grooters
Honored Contributor

Re: Shareable image

A lot of information on writing shareable images on Alpha can be found in the Wizard:
http://h71000.www7.hp.com/wizard/wiz_3309.html is a good starting point.
Best choice is the first link mentioned: http://www.openvms.digital.com/wizard/swdev/ovms-shexe-cook.html

Willem
Willem Grooters
OpenVMS Developer & System Manager
Bojan Nemec
Honored Contributor

Re: Shareable image

Deepak,

Follow others instructions. If you are not familiar with shareable images on VMS C++ is not the best language to start. When you declare entrypoints, as Antonio suggested, you must look for the "real" procedure names. For this you can use the [.cxx_repository]cxx$demangler_db.; file, which has in the first colon the real name and in the second colon the C++ name of the routine (method).

Bojan
Deepak kumar_3
Frequent Advisor

Re: Shareable image

Hi All,

Thanks a lot for all the info. But still i am not able to get very clear way how to creat sharable immage.

Example : i have
a.cpp
b.cpp
c.cpp
now i want to create sharable image t.so how should i proced. In all the above links no where they are telling step by step procedure.

-Deepak
Bojan Nemec
Honored Contributor

Re: Shareable image

Deepark,

Compile all three sources to get the .obj files, then you must create the .opt file where you define which procedures (methods) are global (exported) see Antonios post. To get the names you look to the [.cxx_repository]cxx$demangler_db.; . Maybe copying this file to the .opt file and edit it will be the best solution. When you have the .opt file (say t.opt), link with:

$ CXXLINK/SHAREABLE=t.exe a,b,c,t.opt/OPTIONS

Now you have a T.EXE file, which is a shareable image (like t.so on *NIX).

Now when you want to link this shareable image to another program you have two posibilities:

You can create a new .opt file, where you add a line:

T/SHAREABLE

and use this .opt when linking the programs which use yours T.EXE.

The second posibility is to create a shareable library with:

$ LIBRARY/CREATE/SHARE T.OLB T.EXE

When linking programs you then you link with:

$ LINK program_which_use_t.obj,t.olb/LIBRARY

(or CXXLINK when you are linking C++ programs)

Another posibility is to define a logical name LNK$LIBRARY which points to t.olb (if you have more than one library you start with LNK$LIBRARY then LNK$LIBRARY_1,LNK$LIBRARY_2 and so on logical names). This logical names can be defined in the PROCESS,JOB,GROUP and SYSTEM table. The linker will search all libraryes to resolve symbols. If you define such logical names, there is no need to define anything in the LINK command.

Remeber that shareable images must reside in the SYS$SHARE (or SYS$LIBRARY which is the same) directory or have a logical name which points to the shareable image. The second method is better, because with this you dont mess with system directories. There is an example how to define the logical name for the MYSHAREABLES:T.EXE:

$ DEFINE/table T MYSHAREABLES:T.EXE

the /table qualifier is the table where you want to define the logical. If all users on the system will use this shareable image /SYSTEM will be the right table.


Bojan

Re: Shareable image

Deepak,

The responses to this that I've read so far all appear to be factually correct but they don't seem to address the problems that you are going to run into when you try to do this specifically for C++.

By the way, this is also a non-trivial problem on other platforms.

Let me try and enumerate the problems you will run into.

First, you will be dealing with a large number of mangled names. Trying to manage this is not practical, so you will probably want to automate this by parsing the output of a library/list/names command.

Having done that, the next problem you will encounter is that you will have to determine which entry points are data declarations and which are functions (member or otherwise). Data declarations must use a corresponding SYMBOL_VECTOR(name=DATA) statement rather than SYMBOL_VECTOR(name=PROCEDURE). The only way I know to deal with this is to cxxlink and parse the resulting %LINK-W-SYMVABNORMAL messages, fix up the options file and try again.

You might also want to filter out names that you know you don't need to expose. There are some module initiailzation entry points that really should remain hidden. It helps here if the tool you are using provides regular expressions so you can filter these out based on a pattern.

It would also be nice to be able to filter out (e.g.) private class member functions but I don't know an easy way to do this.

You also need to be sure and compile with /extern_model=strict_refdef/noshare because failing to do that will cause some external references to be weak references which will prevent some names from showing up in the list/list/names.

You might want to consider compiling with /names=as_is and then creating an all upper case alias for each of the names. For example:

SYMBOL_VECTOR=(exampleMixedName=PROCEDURE,EXAMPLEMIXEDNAME/exampleMixedName=PROCEDURE)

The last time I needed to do this I wrote a python script.

HTH,

Bruce
Martin Vorlaender
Honored Contributor

Re: Shareable image

Deepak,

>>>
In all the above links no where they are telling step by step procedure.
<<<

Which of the steps in the OpenVMS Shareable cookbook that Willem pointed you to do you have problems with?

To clarify, here's that link again:
http://www.openvms.digital.com/wizard/swdev/ovms-shexe-cook.html

You can also use http://h71000.www7.hp.com/wizard/swdev/ovms-shexe-cook.html if you have problems with URLs pointing to digital.com.

HTH,
Martin

Re: Shareable image

I started to post a clarification to my previous reply. Now, I think I really need to.

I said:

> The responses to this that I've read so
> far all appear to be factually correct but
> they don't seem to address the problems
> that you are going to run into when you
> try to do this specifically for C++.

Case in point:

> Uh... LINK/SHARE ?

No, that's wrong. You always have to use CXXLINK, not LINK when dealing with C++.

To be fair, though, Hein van den Heuvel was the only one that actually had a C++ specific link:

http://h71000.www7.hp.com/commercial/cplus/alpha_doc/ugvhdr.html#index_x_299

would be a better place to start for a shareable image containing a C++ library.

Martin Vorlaender said:
> To clarify, here's that link again:
> http://www.openvms.digital.com/wizard/swdev/ovms-shexe-cook.html

Sorry, I don't agree that this is the best place to start if you plan to create a shareable image containing C++ code.

Instead, you should start with the C++ specific page that Hein van den Heuvel referenced.

Another example:

> I guess it isn't that much different than
> for instance from modules written in C.

Yes, it is quite different.
Martin Vorlaender
Honored Contributor

Re: Shareable image

Deepak, Bruce,

>>>
> Uh... LINK/SHARE ?

No, that's wrong. You always have to use CXXLINK, not LINK when dealing with C++.
<<<

It fact, you needn't to. CXXLINK performs two major tasks:
- Searches for and adds template instantiations, if needed
- Adds sys$library:libcxxstd.olb to the linker input

If your application uses template instantiations, you would need to link files from your [.cxx_repository] with the application.

Use CXXLINK/LOG to see which LINK operations CXXLINK performs.

>>>
> To clarify, here's that link again:
> http://www.openvms.digital.com/wizard/swdev/ovms-shexe-cook.html

Sorry, I don't agree that this is the best place to start if you plan to create a shareable image containing C++ code.
<<<

While the SW_SHR example sure is helpful, I still think the cookbook is better to understand what steps are required to build a shareable image in general. The mangled names are just an additional obstacle the C++ has.

cu,
Martin
Bojan Nemec
Honored Contributor

Re: Shareable image

Deepak,

There is another consideration. If you need only some functions to be visible from other programs and no class methods, you can declare these functions as extern "C". These function names will not be managled and creating a shareable will be slightly simplier. Of course you can use classes in this functions.

Bojan
Vouters
Advisor

Re: Shareable image

Deepak,

What about http://h18000.www1.hp.com/support/asktima/appl_tools/009EF453-A516039E-1C02A1.html ?
Can't it help you ?

Note this is an inclusive method (i.e.: all external functions are added.) You may have to modify the generated command procedure to replace the link command by cxxlink.
Hoping this can help you.
Regards,
Philippe