[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GnuCOBOL-users] Interfacing COBOL with C
From: |
Simon Sobisch |
Subject: |
[GnuCOBOL-users] Interfacing COBOL with C |
Date: |
Sat, 4 Aug 2018 14:30:39 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
The following thread was originally posted to the bug mailing list (the
last messages under "Bug-GnuCOBOL Digest, Vol 17, Issue 5") and is
hereby "forwarded" to this, more appropriate, list
Simon
Am 04.08.2018 um 13:13 schrieb Ron Norman:
> FYI, There was a fair bit of work that I put into C <--> COBOL interface
> a while ago, but this was done in the reportwriter branch and I don't
> think it has all been merged into the trunk yet.
>
> What I do is generate a a small C 'main' routine that is then link with
> the 1st COBOL module: Example:
>
> extern void tsp();
> extern void tipMainEntry();
> extern void c_tiprtn();
> int
> main(int argc, char **argv)
> {
> /* GnuCOBOL */
> cob_init (0,(void*)0);
> tipMainEntry(tsp,argc,argv,(void*)0,(void*)0);
> c_tiprtn();
> exit(0);
> tsp();
> return 0;
>
>
>
> On Fri, Aug 3, 2018 at 10:20 PM, Michael Potter <address@hidden
> <mailto:address@hidden>> wrote:
>
> I dug into the cobcrun code and saw they were copying the
> COB_LIBRARY_PATH into a separate environment.
>
> I coded that in my .c file _something_ like this:
>
> (void) cob_setenv ("COB_LIBRARY_PATH",
> getenv("COB_LIBRARY_PATH"), 1);
> (void) cob_setenv ("COB_PRE_LOAD", "UNDATE", 1);
>
> LibHandle = dlopen("MYPROG.so", RTLD_NOW);
>
> cob_init(); // Added per James' suggestion.
>
> ProgramEntry = (ProgramEntryType)dlsym(LibHandle, "MYPROG");
>
> ProgramEntry();
>
> If anyone has a good idea of what I should change please speak up.
> If I don't hear anything I will code up a minimal test case and post it.
>
> One issue I have with James' suggestion is it seemed to imply that I
> needed to do cob_init() after dlopen, but will I need to do a dlopen
> before every cobol call.
>
> My code is structured such that c calls COBOL calls c calls COBOL
> calls c ....
>
>
>
>
> On Fri, Aug 3, 2018 at 3:12 PM James K. Lowden
> <address@hidden <mailto:address@hidden>> wrote:
>
> On Wed, 1 Aug 2018 23:21:44 -0400
> Michael Potter <address@hidden <mailto:address@hidden>> wrote:
>
> > libcob: user-defined FUNCTION 'UNDATE' not found
> > when I attempt to load the COBOL program using my own dlopen in my
> > own c program (I am not using cobcrun).
> >
> > I suspect that COB_LIBRARY_PATH is part of cobcrun and
> therefore not
> > used in my c program.
>
> Are you calling cob_init after dlopen and before calling any cobol
> function?
>
> I would expect COB_LIBRARY_PATH to affect the Cobol runtime support,
> not cobcrun per se.
>
> --jkl
>
>
>
>
>
> --
> Cheers
> Ron Norman
- [GnuCOBOL-users] Interfacing COBOL with C,
Simon Sobisch <=