I have an existing C++ application. It links to a library that in
turn talks to DB2, using a sidedeck that names DSNAOCLI functions. In
order to get access to the DB2 interfaces, another program sets
STEPLIB to <dsn>.SDSNLOAD, where <dsn> is the name of the database
instance. This other program then execs the application.
This works fine. However, I'd like to make the application load that
library dynamically, using dlopen or dllload. I've been successful in
doing that part -- the DLL loads into the application and at least
starts to run -- but I have questions about STEPLIB.
I would like to eliminate the need for the other program to set
STEPLIB before starting the application, because the point of doing
the dynamic loading is to make the application configurable at run
time by loading different DLLs. I can either arrange for the
application calling dlopen() to set up the environment variables or
make special calls before that DLL is loaded, or I can modify the
loaded library (that talks to DB2) to do something to get access to
DSNAOCLI.
However, I'm stuck. If STEPLIB is set before the program runs (not
what I want), then everything works. If it's not set, then I get
"CEE3501S The module DSNAOCLI was not found."
It doesn't matter what I do. If I set STEPLIB (by putenv()) inside
the application calling dlopen(), it makes no difference; the
application behaves as though it were not set. If I try do do a
dlopen of "//<dsn>" or "//DSNAOCLI" or any of a number of other things
before loading the DLL, it doesn't change the behavior.
The system seems to behave as though STEPLIB is evaluated exactly once
when a program starts running, and then never again afterwards. (I
have searched for several hours, and I have not located any clear
documentation on the behavior of the STEPLIB variable -- only a great
number of references to how it's set in /etc/profile or how it's used
with WebSphere -- so it's entirely likely that my ignorance on basic
MVS architecture is showing here.)
So the basic question is this: I have a running application that will
load a DLL, and the DLL it loads in turn depends on an MVS library
that is ordinarily loaded by STEPLIB. How can I arrange to have this
dependency resolved properly?
STEPLIB appears (to my untrained eye) to be something like a library
search list, but I can't change it for the current process
("enclave?") at run time. Is there some way to change this value at
run time, or at least tell the system to look at the value again? Or
some way to tell the DLL that it needs to go looking in a configurable
location to get the libraries it needs?