I am trying to call a C++ program from a Cobol program. I have searched all over for 3.5 weeks, and this is driving me crazy. I am running CYGWIN on a windows 7 machine. My UNIX is very novice.
My c++ program computes a sha256 hash algorithm. I know it works, as i have successfully called it from another C++ program, and verified the results.
My problem is that when I try to dynamically link the main cobol program with the C++ sub program, everything looks fine on the surface. But when I execute the main program, and it calls the C++ program, I get the message displayed on the console: libcob: Cannot find module 'SUBC'.
Here are the steps I followed to compile the main program and link it with the C++ subprogram, as per OpenCobol
1.) $ cobc -x CALLSHA.cbl --- Compile the calling program
2.) $ g++ -shared -o SUBC.so SUBC.cpp --- Compile C++ sub program
3.) $ cp SUBC.so /Lib --- install the module in library directory
4.) $ export COB_LIBRARY_PATH=/Lib ---
5.) $ ./CALLSHA --- Run main program which is dynamically linked with C++ module
HERE IS THE OUTPUT FROM THE RUN:
CALL from main. --- Message produced in main program right before the call
libcob: Cannot find module 'SUBC' --- Error message says C++ program not found
Yes, I have been using those as a guide. The thing is, those compile examples are in C, not C++.
The second thing is that, my main program is a cobol program that calls a C++ program. The second link you posted is the reverse of that.
I realize that you have to use the g++ compiler instead of CC.
When I tried to compile and LINK the 2 programs "Statically", I was getting errors, even though compiling them seperately was no problem.
When I compiled and Linked them "Dynamically", I was able to get it compiled and Linked, but when the program is run, the c++ module when called by Cobol gives the error: libcob: Cannot find module 'SUBC'.
I will post the code a little later, along with the compile and link steps. I have tried many things. I never thought I would have this much trouble finding an example of a Cobol Program Calling a C++. But then again, as I said straight away, I am not a Unix guru.