6 .Nd load and link a dynamic library or bundle
10 .Fn dlopen "const char* path" "int mode"
13 examines the mach-o file specified by
15 If the file is compatible with the current process and has not already been
16 loaded into the current process, it is loaded and linked. After being linked,
17 if it contains any initializer functions, they are called, before
21 can load dynamic libraries and bundles. It returns a handle that can
28 with the same path will return the same handle, but the internal reference
29 count for the handle will be incremented. Therefore all
31 calls should be balanced with a
35 If a null pointer is passed in
38 returns a handle equivalent to RTLD_DEFAULT.
43 It must contain one or more of the following values, possibly ORed together:
45 .Bl -tag -width RTLD_LAZYX
47 Each external function reference is bound the first time the function is called.
49 All external function references are bound immediately during the call to
54 is normally preferred, for reasons of efficiency.
57 is useful to ensure that any undefined symbols are discovered during the
61 RTLD_LAZY nor RTLD_NOW is specified, the default is RTLD_LAZY.
63 One of the following flags may be ORed into the
66 .Bl -tag -width RTLD_GLOBALX
68 Symbols exported from this image (dynamic library or bundle) will be available to any
69 images build with -flat_namespace option to
73 when using a special handle.
75 Symbols exported from this image (dynamic library or bundle) are generally hidden
78 when directly using the handle returned by this call to
81 RTLD_GLOBAL nor RTLD_LOCAL is specified, the default is RTLD_GLOBAL.
85 uses a series of steps to find a compatible mach-o file. The first compatible file found is used.
87 1) If the directory specified by
89 does not contain a slash '/' (i.e. it is a leaf name) then the environment variable LD_LIBRARY_PATH is
90 used. LD_LIBRARY_PATH should be a colon seperated list of directories.
92 searches each directory, in the order specified, for the leaf name
95 2) If DYLD_LIBRARY_PATH is set, then those directories are searched, in order,
99 3) If DYLD_FALLBACK_LIBRARY_PATH is set, then those directories are searched, in order
100 with the leaf name of
102 If DYLD_FALLBACK_LIBRARY_PATH is not set, then the following directories are searched: $HOME/lib, /usr/local/lib, /usr/lib
106 is tried as-is as a regular file path. That means it might resolve relative to the current working directory.
108 Note: There are no configuration files to control dlopen searching.
110 Note: Mac OS X uses "fat" files to combine 32-bit and 64-bit libraries. This means there are no separate 32-bit and 64-bit search paths.
115 fails, it returns a null pointer, and sets an error condition which may be interrogated with
118 Mac OS X 10.3 incorporated the dlcompat package written by Jorge Acereda <jacereda@users.sourceforge.net>
119 and Peter O'Gorman <ogorman@users.sourceforge.net>.
121 In Mac OS X 10.4, dlopen was rewritten to be a native part of dyld.