Skip to main content

[archive] call C routine

  • April 24, 2008
  • 2 replies
  • 0 views

[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

2 replies

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

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