链接DataStage提供库文件总是失败,也不知道是什么原因。刚刚在Information Center查到dlopen的详细说明,贴在这里吧。
IBM的资料真是浩如烟海啊。。。
FROM http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/dlopen.htm
dlopen Subroutine
Purpose
Dynamically loads a module into the calling process.
Syntax
#include <dlfcn.h>
void *dlopen (FilePath , Flags ); const char * FilePath ; int Flags ;
Description
The dlopen subroutine loads the module specified by FilePath into the executing process's address space. Dependents of the module are automatically loaded as well. If the module is already loaded, it is not loaded again, but a new, unique value will be returned by the dlopen subroutine.
The dlopen subroutine is a portable way of dynamically loading shared libraries. It performs C++ static initialization of the modules that it loads, like the loadAndInit subroutine does.
The value returned by the dlopen might be used in subsequent calls to dlsym and dlclose . If an error occurs during the operation, dlopen returns NULL .
If the main application was linked with the -brtl option, then the runtime linker is invoked by dlopen . If the module being loaded was linked with runtime linking enabled, both intra-module and inter-module references are overridden by any symbols available in the main application. If runtime linking was enabled, but the module was not built enabled, then all inter-module references will be overridden, but some intra-module references will not be overridden.
If the module being opened with dlopen or any of its dependents is being loaded for the first time, initialization routines for these newly-loaded routines are called (after runtime linking, if applicable) before dlopen returns. Initialization routines are the functions specified with the -binitfini: linker option when the module was built. (See the ld command for more information about this option.)
After calling the initialization functions for all newly-loaded modules, C++ static initialization is performed. If you call the dlopen subroutine from within an initialization function or a C++ static initialization function, modules loaded by the nested dlopen subroutine might be initialized before completely initializing the originally loaded modules.
If a dlopen subroutine is called from within a binitfini function, the initialization of the current module is abandoned for other modules.
The LIBPATH or LD_LIBRARY_PATH environment variables can be used to specify a list of directories in which the dlopen subroutine searches for the named module. The running application also contains a set of library search paths that were specified when the application was linked. The dlopen subroutine searches the modules based on the mechanism that the load subroutine (load and loadAndInit Subroutines ) defines, because the dlopen subroutine internally calls the load subroutine with the L_LIBPATH_EXEC flag.
Flags
Specifies variations of the behavior of dlopen . Either RTLD_NOW or RTLD_LAZY must always be specified. Other flags may be OR'ed with RTLD_NOW or RTLD_LAZY .
Return Values
Upon successful completion, dlopen returns a value that can be used in calls to the dlsym and dlclose subroutines. The value is not valid for use with the loadbind and unload subroutines.
If the dlopen call fails, NULL (a value of 0) is returned and the global variable errno is set. If errno contains the value ENOEXEC , further information is available via the dlerror function.
Error Codes
See the load subroutine for a list of possible errno values and their meanings.
Related Information
The dlclose (dlclose Subroutine ) subroutine, dlerror (dlerror Subroutine ) subroutine, load (load and loadAndInit Subroutines ) subroutine, loadbind (loadbind Subroutine ) subroutine, loadquery (loadquery Subroutine )subroutine, unload subroutine.
The ld command.
Subroutines Overview di in AIX 5L Version 5.3 General Programming Concepts: Writing and Debugging Programs .
The Dynamically loading a shared library section in the XL C/C++ V8.0 for AIX Programming Guide book.