The loadAndInit function takes the same parameters and returns the same values and error codes as the load routine. See the load routine in the Technical Reference: Base Operating System and Extensions, Volumes 1 & 2 for more information.
#include <load.h> int (*loadAndInit(char *FilePath, unsigned int Flags, char *LibraryPath))();
The loadAndInit function calls the AIX® load routine to load the specified module (shared library) into the calling process's address space. If the shared library is loaded successfully, any C++ initialization is performed. The loadAndInit function ensures that a shared library is only initialized once, even if dlopen is used to load the library too. Subsequent loads of the same shared library will not perform any initialization of the shared library.
If loading a shared library results in other shared libraries being loaded, the initialization for those shared libraries will also be performed (if it has not been previously). If loading a shared library results in the initialization of multiple shared libraries, the order of initialization is determined by the priority assigned to the shared libraries when they were built. Shared libraries with the same priority are initialized in random order.
To terminate and unload the shared library, use the terminateAndUnload function, described below.
Do not reference symbols in the C++ initialization that need to be resolved by a call to the AIX loadbind routine, since the loadbind routine normally is not called until after the loadAndInit function returns.
Upon successful completion, the loadAndInit function returns the pointer to function for the entry point (or data section) of the shared library.
If the loadAndInit function fails, a null pointer is returned, the module is not loaded or initialized, and the errno global variable is set to indicate the error.