Top Description Fields Constructors Methods
org.lwjgl.system.macosx

public Class DynamicLinkLoader

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.system.*

Native bindings to <dlfcn.h>.

Field Summary

Modifier and TypeField and Description
public static final long
RTLD_DEFAULT

Special-handle values for dlsym.

public static final int
RTLD_GLOBAL

The mode argument to dlopen contains one of the following.

public static final int
RTLD_LAZY

The mode argument to dlopen contains one of the following.

public static final int
RTLD_LOCAL

The mode argument to dlopen contains one of the following.

public static final long
RTLD_MAIN_ONLY

Special-handle values for dlsym.

public static final long
RTLD_NEXT

Special-handle values for dlsym.

public static final int
RTLD_NOW

The mode argument to dlopen contains one of the following.

public static final long
RTLD_SELF

Special-handle values for dlsym.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static int
dlclose(long
a handle obtained through a call to dlopen.
handle
)

Closes a dynamic library or bundle.

public static String
dlerror()

Provides diagnostic information corresponding to problems with calls to dlopen, dlsym, and dlclose in the same thread.

public static long
dlopen(ByteBuffer
path to the image to open
path
,
int
specifies when the loaded image's external symbols are bound to their definitions in dependent libraries (lazy or at load time) and the visibility of the image's exported symbols (global or local). The value of this parameter is made up by ORing one binding behavior value with one visibility specification value.

The following values specify the binding behavior:

  • RTLD_LAZY (default): Each external symbol reference is bound the first time it's used.
  • RTLD_NOW: All external symbol references are bound immediately.

The following values specify external symbol visibility:

  • RTLD_GLOBAL (default): The loaded image's exported symbols are available to any images that use a flat namespace or to calls to dlsym when using a special handle (see dlsym for details).
  • RTLD_LOCAL: The loaded image's exported symbols are generally hidden. They are available only to dlsym invocations that use the handle returned by this function.
mode
)

Loads and links a dynamic library or bundle.

public static long
dlopen(CharSequence
path to the image to open
path
,
int
specifies when the loaded image's external symbols are bound to their definitions in dependent libraries (lazy or at load time) and the visibility of the image's exported symbols (global or local). The value of this parameter is made up by ORing one binding behavior value with one visibility specification value.

The following values specify the binding behavior:

  • RTLD_LAZY (default): Each external symbol reference is bound the first time it's used.
  • RTLD_NOW: All external symbol references are bound immediately.

The following values specify external symbol visibility:

  • RTLD_GLOBAL (default): The loaded image's exported symbols are available to any images that use a flat namespace or to calls to dlsym when using a special handle (see dlsym for details).
  • RTLD_LOCAL: The loaded image's exported symbols are generally hidden. They are available only to dlsym invocations that use the handle returned by this function.
mode
)

Loads and links a dynamic library or bundle.

public static long
dlsym(long
a handle obtained by a call to dlopen, or a special handle. If the handle was obtained by a call to dlopen, it must not have been closed with a call to dlclose. These are the possible special-handle values: RTLD_DEFAULT, and RTLD_NEXT.
handle
,
ByteBuffer
the null-terminated character string containing the C name of the symbol being sought
name
)

Returns the address of a symbol.

public static long
dlsym(long
a handle obtained by a call to dlopen, or a special handle. If the handle was obtained by a call to dlopen, it must not have been closed with a call to dlclose. These are the possible special-handle values: RTLD_DEFAULT, and RTLD_NEXT.
handle
,
CharSequence
the null-terminated character string containing the C name of the symbol being sought
name
)

Returns the address of a symbol.

public static native int
ndlclose(long handle)

Unsafe version of: dlclose

public static native long
ndlerror()

Unsafe version of: dlerror

public static native long
ndlopen(long path, int mode)

Unsafe version of: dlopen

public static native long
ndlsym(long handle, long name)

Unsafe version of: dlsym

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

RTLD_DEFAULTback to summary
public static final long RTLD_DEFAULT

Special-handle values for dlsym.

RTLD_GLOBALback to summary
public static final int RTLD_GLOBAL

The mode argument to dlopen contains one of the following.

RTLD_LAZYback to summary
public static final int RTLD_LAZY

The mode argument to dlopen contains one of the following.

RTLD_LOCALback to summary
public static final int RTLD_LOCAL

The mode argument to dlopen contains one of the following.

RTLD_MAIN_ONLYback to summary
public static final long RTLD_MAIN_ONLY

Special-handle values for dlsym.

RTLD_NEXTback to summary
public static final long RTLD_NEXT

Special-handle values for dlsym.

RTLD_NOWback to summary
public static final int RTLD_NOW

The mode argument to dlopen contains one of the following.

RTLD_SELFback to summary
public static final long RTLD_SELF

Special-handle values for dlsym.

Constructor Detail

DynamicLinkLoaderback to summary
protected DynamicLinkLoader()

Method Detail

dlcloseback to summary
public static int dlclose(long handle)

Closes a dynamic library or bundle.

This function decreases the reference count of the image referenced by handle. When the reference count for handle becomes 0, the termination routines in the image are called, and the image is removed from the address space of the current process. After that point, handle is rendered invalid.

Parameters
handle:long

a handle obtained through a call to dlopen.

dlerrorback to summary
public static String dlerror()

Provides diagnostic information corresponding to problems with calls to dlopen, dlsym, and dlclose in the same thread.

When there's a problem to report, this function returns a pointer to a null-terminated string describing the problem. Otherwise, this function returns NULL.

Each call to dlerror resets its diagnostic buffer. If a program needs to keep a record of past error messages, it must store them itself. Subsequent calls to dlerror in the same thread with no calls to dlopen, dlsym, or dlclose, return NULL.

Annotations
@Nullable
@NativeType:char const *
dlopenback to summary
public static long dlopen(ByteBuffer path, int mode)

Loads and links a dynamic library or bundle.

This function examines the Mach-O file specified by path. If the image is compatible with the current process and has not already been loaded into the process, the image is loaded and linked. If the image contains initializer functions, they are executed before this function returns.

Subsequent calls to dlopen to load the same image return the same handle, but the internal reference count for the handle is incremented. Therefore, all dlopen calls must be balanced with dlclose calls.

For efficiency, the RTLD_LAZY binding mode is preferred over RTLD_NOW. However, using RTLD_NOW ensures that any undefined symbols are discovered during the call to dlopen.

The dynamic loader looks in the paths specified by a set of environment variables, and in the process's current directory, when it searches for a library. These paths are called dynamic loader search paths. The environment variables are LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, and DYLD_FALLBACK_LIBRARY_PATH. The default value of DYLD_FALLBACK_LIBRARY_PATH (used when this variable is not set), is $HOME/lib;/usr/local/lib;/usr/lib.

The order in which the search paths are searched depends on whether path is a filename (it does not contain a slash) or a pathname (it contains at least one slash).

When path is a filename, the dynamic loader searches for the library in the search paths in the following order:

  • $LD_LIBRARY_PATH
  • $DYLD_LIBRARY_PATH
  • The process's working directory
  • $DYLD_FALLBACK_LIBRARY_PATH

When path is a pathname, the dynamic loader searches for the library in the search paths in the following order:

  • $DYLD_LIBRARY_PATH
  • The given pathname
  • $DYLD_FALLBACK_LIBRARY_PATH using the filename
Parameters
path:ByteBuffer

path to the image to open

mode:int

specifies when the loaded image's external symbols are bound to their definitions in dependent libraries (lazy or at load time) and the visibility of the image's exported symbols (global or local). The value of this parameter is made up by ORing one binding behavior value with one visibility specification value.

The following values specify the binding behavior:

  • RTLD_LAZY (default): Each external symbol reference is bound the first time it's used.
  • RTLD_NOW: All external symbol references are bound immediately.

The following values specify external symbol visibility:

  • RTLD_GLOBAL (default): The loaded image's exported symbols are available to any images that use a flat namespace or to calls to dlsym when using a special handle (see dlsym for details).
  • RTLD_LOCAL: The loaded image's exported symbols are generally hidden. They are available only to dlsym invocations that use the handle returned by this function.
Annotations
@NativeType:void *
dlopenback to summary
public static long dlopen(CharSequence path, int mode)

Loads and links a dynamic library or bundle.

This function examines the Mach-O file specified by path. If the image is compatible with the current process and has not already been loaded into the process, the image is loaded and linked. If the image contains initializer functions, they are executed before this function returns.

Subsequent calls to dlopen to load the same image return the same handle, but the internal reference count for the handle is incremented. Therefore, all dlopen calls must be balanced with dlclose calls.

For efficiency, the RTLD_LAZY binding mode is preferred over RTLD_NOW. However, using RTLD_NOW ensures that any undefined symbols are discovered during the call to dlopen.

The dynamic loader looks in the paths specified by a set of environment variables, and in the process's current directory, when it searches for a library. These paths are called dynamic loader search paths. The environment variables are LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, and DYLD_FALLBACK_LIBRARY_PATH. The default value of DYLD_FALLBACK_LIBRARY_PATH (used when this variable is not set), is $HOME/lib;/usr/local/lib;/usr/lib.

The order in which the search paths are searched depends on whether path is a filename (it does not contain a slash) or a pathname (it contains at least one slash).

When path is a filename, the dynamic loader searches for the library in the search paths in the following order:

  • $LD_LIBRARY_PATH
  • $DYLD_LIBRARY_PATH
  • The process's working directory
  • $DYLD_FALLBACK_LIBRARY_PATH

When path is a pathname, the dynamic loader searches for the library in the search paths in the following order:

  • $DYLD_LIBRARY_PATH
  • The given pathname
  • $DYLD_FALLBACK_LIBRARY_PATH using the filename
Parameters
path:CharSequence

path to the image to open

mode:int

specifies when the loaded image's external symbols are bound to their definitions in dependent libraries (lazy or at load time) and the visibility of the image's exported symbols (global or local). The value of this parameter is made up by ORing one binding behavior value with one visibility specification value.

The following values specify the binding behavior:

  • RTLD_LAZY (default): Each external symbol reference is bound the first time it's used.
  • RTLD_NOW: All external symbol references are bound immediately.

The following values specify external symbol visibility:

  • RTLD_GLOBAL (default): The loaded image's exported symbols are available to any images that use a flat namespace or to calls to dlsym when using a special handle (see dlsym for details).
  • RTLD_LOCAL: The loaded image's exported symbols are generally hidden. They are available only to dlsym invocations that use the handle returned by this function.
Annotations
@NativeType:void *
dlsymback to summary
public static long dlsym(long handle, ByteBuffer name)

Returns the address of a symbol.

The value of handle specifies what images this function searches for to locate the symbol specified by the symbol parameter. The following table describes the possible values for the handle parameter:

Handle valueSearch scope
dlopen handleImage associated with the dlopen handle.
RTLD_DEFAULTEvery dependent library or RTLD_GLOBAL–opened library in the current process, in the order they were loaded.
RTLD_NEXTDependent libraries that were loaded after the one calling this function. Libraries opened with dlopen are not searched.

Unlike in the NS... functions, the symbol parameter doesn't require a leading underscore to be part of the symbol name.

Parameters
handle:long

a handle obtained by a call to dlopen, or a special handle. If the handle was obtained by a call to dlopen, it must not have been closed with a call to dlclose. These are the possible special-handle values: RTLD_DEFAULT, and RTLD_NEXT.

name:ByteBuffer

the null-terminated character string containing the C name of the symbol being sought

Annotations
@NativeType:void *
dlsymback to summary
public static long dlsym(long handle, CharSequence name)

Returns the address of a symbol.

The value of handle specifies what images this function searches for to locate the symbol specified by the symbol parameter. The following table describes the possible values for the handle parameter:

Handle valueSearch scope
dlopen handleImage associated with the dlopen handle.
RTLD_DEFAULTEvery dependent library or RTLD_GLOBAL–opened library in the current process, in the order they were loaded.
RTLD_NEXTDependent libraries that were loaded after the one calling this function. Libraries opened with dlopen are not searched.

Unlike in the NS... functions, the symbol parameter doesn't require a leading underscore to be part of the symbol name.

Parameters
handle:long

a handle obtained by a call to dlopen, or a special handle. If the handle was obtained by a call to dlopen, it must not have been closed with a call to dlclose. These are the possible special-handle values: RTLD_DEFAULT, and RTLD_NEXT.

name:CharSequence

the null-terminated character string containing the C name of the symbol being sought

Annotations
@NativeType:void *
ndlcloseback to summary
public static native int ndlclose(long handle)

Unsafe version of: dlclose

ndlerrorback to summary
public static native long ndlerror()

Unsafe version of: dlerror

ndlopenback to summary
public static native long ndlopen(long path, int mode)

Unsafe version of: dlopen

ndlsymback to summary
public static native long ndlsym(long handle, long name)

Unsafe version of: dlsym