dlopen()

gain access to an executable object file 

Function


SYNOPSIS

#include <dlfcn.h>

void *dlopen(const char *file, int mode);


DESCRIPTION

dlopen() makes an executable object file specified by file available to the calling program. A successful dlopen() returns a handle for use in subsequent calls to dlsym() and dlclose(). The value of this handle should not be interpreted in any way by the caller. Only a single copy of the object file is brought into the address space, even if dlopen() is invoked multiple times in reference to the file, and even if different path names are used to reference the file.


PARAMETERS

file 

Specifies the object file to load. If file is not an absolute path, an implementation-defined algorithm is used to locate the file. If file is NULL, dlopen() provides a handle to the calling program itself.

mode 

Specifies the mode in which symbols should be bound. This may be either RTLD_LAZY or RTLD_NOW. These values are interpreted identically; symbols are always bound at load time. Both are recognized for maximum source compatibility, since there is no operational difference.


RETURN VALUES

On success, dlopen() returns a pointer which can be passed in subsequent calls to dlsym() and dlclose(). It returns a NULL on return. More detailed diagnostic information is available through the dlerror() function.


CONFORMANCE

UNIX 98, with exceptions.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

dlopen() is implemented as a pass-through to the Win32 function LoadLibrary(), and hence does not have all of the features available on some UNIX platforms. The modes RTLD_LAZY and RTLD_NOW are interpreted identically, and the modifiers RTLD_GLOBAL and RTLD_LOCAL specified in UNIX 98 are ignored (the Windows behavior is always equivalent to RTLD_NOW|RTLD_LOCAL). Please refer to the Win32 online documentation for more detailed information, in particular, the search order used if name is not an absolute path.

File names are treated as multibyte sequences and are converted to Unicode (UTF-16) before passing to Win32. The conversion is either performed based on the current thread locale, set using uselocale() or the process locale as set by a call to setlocale(), and overridden by _NutConf() _NC_SET_ANSI_LOCALE and _NC_SET_UTF8_LOCALE options. Under all other conditions, the multibyte sequences are considered to be from the ANSI code page for the current windows system locale.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
dlclose(), dlerror(), dlsym()


PTC MKS Toolkit 10.3 Documentation Build 39.