Operating System - OpenVMS
1748210 Members
2964 Online
108759 Solutions
New Discussion юеВ

Call C++ routine in shareable from C main program

 
SOLVED
Go to solution
Jean-Fran├зois Pi├йronne
Trusted Contributor

Call C++ routine in shareable from C main program

Hello,

I need to call, from C, routines in a shareable build from a library written in C++ (AXP and IA64 C and C++ version: 7.3-009)

My main program is in C, so I want to know if I have to call some special initialization C++ runtime routine like you have to do for C (DECC$CRTL_INIT routine) when you call C routine from others languages.

Thanks,

Jean-Fran├зois
4 REPLIES 4
Hein van den Heuvel
Honored Contributor

Re: Call C++ routine in shareable from C main program

Jean-Fran├Г┬зois,

You strike me as the kind of guy who would just try first.
Did you? What seemed to be the problem?

Shareable libraries do their own initialization stuff upon their activation (LIB$FIS time, or along with main), through the LIB$INITIALIZE psect magic.

Sorry, no actual experience with this myself.

Hein.

Bojan Nemec
Honored Contributor
Solution

Re: Call C++ routine in shareable from C main program

Jean-Francois,

I have many shareables writen in C++ and called from various languages (C,COBOL) and have never have any initialization problems.
The shareables are linked with CXXLINK and the visible functions (which are many times wrappers) are declared in an extern "C" block.

Bojan
Jean-Fran├зois Pi├йronne
Trusted Contributor

Re: Call C++ routine in shareable from C main program

Thanks,

Hein,
I haven't any problem, I try just to not have any.
For example I call DECC$CRTL_INIT using LIB$INITIALIZE psect for the python shareable image.

So I was just wondering if this was not the same for C++.

Bojan,
does this mean that you don't even call DECC$CRTL_INIT in your shareable? I have thought that it's mandatory it you use C routine from another language.

JF
Bojan Nemec
Honored Contributor

Re: Call C++ routine in shareable from C main program

Jean-Francois,

Yes, I don't call DECC$CRTL_INIT in my shareables.

Probably my shareables do not use any of the mentioned functionalities mentioned in:

http://h71000.www7.hp.com/DOC/83final/5763/5763pro_028.html#index_x_750

(but thats not realy true, I am sure that I do some I/O)

Bojan