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