Highlighted
Absent Member.
Absent Member.
263 views

[archive] call C routine

[Migrated content. Thread originally posted on 23 April 2008]

How do I call a C routine in Linux from inside the Cobol program?

COBOL program:

CALL "timerapi.o" USING BY VALUE 20.


C routine:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

int timerapi ( unsigned int msecs )
{
int waitms;

waitms = msecs * 10000;

usleep( waitms );

return(0);
}

The error log says timerapi is not a COBOL program

What did I do wrong here?

Thanks
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] call C routine

How do I call a C routine in Linux from inside the Cobol program?


You cannot call an object file. You will have to call functions in the object file. To do this, you need to relink the runtime. If you check out documentations, book "A guide to interoperating with ACUCOBOL-GT", chapter 4 "Working with C and C++ programs", the topic is extensively covered. For relinking have a look in the lib directory of your installation for example files.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] call C routine

You cannot call an object file. You will have to call functions in the object file. To do this, you need to relink the runtime. If you check out documentations, book "A guide to interoperating with ACUCOBOL-GT", chapter 4 "Working with C and C++ programs", the topic is extensively covered. For relinking have a look in the lib directory of your installation for example files.


Thank you very much, gforseth! I will take a look at documentations.
0 Likes
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.