On Tuesday, November 12, as part of a company wide initiative to bring all corporate websites under the OpenText brand, the Community will be down briefly around 11am Eastern / 8am Pacific as we transition to a new domain name.  The community will be offline while we make the change and when it comes back online it will be located at community.opentext.com and the old domain will redirect to this new location.  Thank you for your patience as we make this important change.

Wikis - Page

COBOL calling a C function within a library using the INITCALL directive.

0 Likes

Problem:

On Linux/Unix, a COBOL program can call a C function within a library using INITCALL, but on Windows, it gives error: 173 Called program file not found in drive/directory.

Resolution:

INITCALL loads the dll/so, but it needs to know what entry is being called within it.  One way to achieve this is by having the same entry name as the binary module itself.  However, there might be several entries in the dll/so that would need to be called separately. In this scenario, INITCALL behaves differently in Linux/Unix compared to Windows.

When the entry and the shared object name are different, on Linux/Unix, the entry can be called by using the "-e name" flag at compilation time.

On Windows, if the Cobol program cannot find an entry with the same name as the dll/so, the first entry in ordinal position is called. To change this behaviour, any entry within the dll that is to be called by COBOL must be exported. For this, a .def file must be created for the dll containing the relevant entry points. Example:

EXPORTS

Entry1

Entry2

Entry3

Then, the .def file must be compiled together with the C source when creating the dll:

cl /LD program.c entryfile.def

Note that the Cobol program and the dll must be in the same directory or on %PATH%.

Comment List
Related
Recommended