Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

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

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


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.


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:





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%.


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2018-06-15 13:48
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.