Calling a C++ dll from COBOL



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Calling a C++ dll from COBOL

Postby rajsara » Sat Sep 20, 2008 6:55 pm

Hi,

My goal is to call a C++ function from COBOL. I am using a V3 Fujitsu Cobol compiler for students.

My sample COBOL code, sample.cob looks as below:
000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. 'HELLO WORLD'.
000030 ENVIRONMENT DIVISION.
000031
000040 DATA DIVISION.
000041 WORKING-STORAGE SECTION.
000043 01 parameters.
000044 02 InputString PIC X(19).
000045
000050 PROCEDURE DIVISION.
000060 MAIN.
000061 CALL "MYFUNCTION" WITH C LINKAGE USING BY REFERENCE InputString.
000070 DISPLAY 'HELLO WORLD'.
000080 STOP RUN.
000090

MYFUNCTION is the exported function from MYFUNCTION.dll . I am trying to call this function from my cobol program.

1. I compiled the COBOL code with the compiler options of NOALPHAL, DLOAD, MAIN.
2. Linked the COBOL code with the MYFUNCTION.lib.
3. Made the entry definition in the COBOL85.CBR as MYFUNCTION=MYFUNCTION.DLL
4. But when I try to execute my cobol program, it prompts "JMP0015I-U CANNOT CALL PROGRAM "MYFUNCTION'. PGM=SAMPLE ADR 004011C6".

I am a beginner to COBOL. Can anyone please let me know, how to solve this problem. I greatly appreciate your help in this regard. Expecting your earliest reply. Thank you in advance.
rajsara
 
Posts: 3
Joined: Sat Sep 20, 2008 6:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Calling a C++ dll from COBOL

 

Re: Calling a C++ dll from COBOL

Postby dick scherrer » Sat Sep 20, 2008 8:05 pm

Hello rajsara and welceomt to the forums,

1. are you running on an IBM mainframe or some other system?

2. please post the jcl and the output from the link editor step.

4. The JMP0015I message should be documented in the messages for your envirnment. Look there for a more complete description of the error.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Calling a C++ dll from COBOL

Postby rajsara » Sat Sep 20, 2008 8:32 pm

Thank you for your reply. I am running on Windows environment with Fujitsu V3 compiler. I am not sure of how I should link and execute the C++ dll's from COBOL.

1) Will I be able to call C++ dlls from COBOL? Is that possible?

2) Do I need to make use of C++ obj file also for COBOL? Can you please let me know of how I should link the .obj file in COBOL?

3) I have used only .lib and .dll of C++. Do I need do anything else?

Your immediate help is greatly appreciate.
Thank you.
rajsara
 
Posts: 3
Joined: Sat Sep 20, 2008 6:52 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Calling a C++ dll from COBOL

Postby dick scherrer » Sat Sep 20, 2008 11:42 pm

Hello,

Will I be able to call C++ dlls from COBOL? Is that possible?
I should think so.

Can you please let me know of how I should link the .obj file in COBOL?
You will possibly need to name it in the linker. I have not done this on Windows, but maybe someone who participates in the forum has. When i used MicroFocus COBOL on UNIX some years ago, i recall that we named the libraries that contained any called modules in a "path" as well as syntax in the link. It has been more than 10 years and none of that material is still at my fingertips (or braintip ;) ). If may be on some disks somewhere, but it would take a while to locate them.

I have used only .lib and .dll of C++. Do I need do anything else?
I would expect that Fijitsu documentation to include the directions on how to use .dll libraries.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post