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 <pottmi@xxxxxxxxx > <mailto:pottmi@xxxxxxxxx>> 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 > <jklowden@xxxxxxxxxxxxxxx <mailto:jklowden@xxxxxxxxxxxxxxx>> wrote: > > On Wed, 1 Aug 2018 23:21:44 -0400 > Michael Potter <pottmi@xxxxxxxxx <mailto:pottmi@xxxxxxxxx>> 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