Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CALLING C++ PROGRAMS

Status
Not open for further replies.

rackp

Programmer
Joined
Dec 31, 2003
Messages
2
Location
GB
Hi

I have been trying to call a C++ dll in a cobol program but the after the build which is sucessful the dll is not loaded and the functions within the dll are not being accessed. Can anyone help Please...
 
Platform? Sample code? Any error message?
 
i am using fujitsu cobol, which is net cobol but not .net cobol.
No error messages but can't find the function in the dll. The dll is written in C++ with 'extern c' and the platform is windows 2000 professional.
i have used the following code to
* TEST TO CALL AUDIT PROGRAM
MOVE "AUDIT5" TO PROGRAM-TO-CALL
MOVE "STARTPROCESS" TO FUNCTION-TO-CALL
MOVE "GNSSTART" & X"00" TO SCRIPT-NAME
MOVE "LAWTEST" & X"00" TO PROCESS-NAME
MOVE "1.0" & X"00" TO VERSION
MOVE "GNS0101" & X"00" TO CYCLE-NAME


CALL PROGRAM-TO-CALL
ON EXCEPTION DISPLAY "CALL TO AUDIT PROGRAM FAILED"
NOT ON EXCEPTION DISPLAY "CALL TO AUDIT PROGRAM SUCCESSFUL"
END-CALL

CALL FUNCTION-TO-CALL
USING BY CONTENT SCRIPT-NAME
BY CONTENT PROCESS-NAME
BY CONTENT VERSION
BY CONTENT CYCLE-NAME
ON EXCEPTION DISPLAY "CALL TO AUDIT FUNCTION FAILED"
NOT ON EXCEPTION DISPLAY "CALL TO AUDIT FUNCTION SUCCESSFUL"
END-CALL

CANCEL FUNCTION-TO-CALL
CANCEL PROGRAM-TO-CALL
 
Try static linking by not putting the function name in a variable:
- If PROGRAM-TO-CALL ("AUDIT5") is meant for loading the dll, delete the entire statement, it is not necessary when static linking is used.
- Delete the two cancel statements.
- Delete the FUNCTION-TO-CALL variable and change the call-styatement to call it direct, CALL "STARTPROCESS" USING ...
When linking the program, include <dllname>.lib, which will be generated when compiling the dll.

Marcel
 
I noticed you did not specify calling conventions. Here is what the manual says about that.

Calling C Programs from COBOL Programs:

When the calling conventions is omitted, its assumed COBOL calling conventions.

Have you tried &quot;CALL 'PGM' USING C LINKAGE&quot; or
&quot;CALL 'PGM' USING STDCALL LINKAGE&quot;.

I have not ever tried this myself however, thought this information may be helpful. Goodluck.

etom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top