Home

dlerror

dlerror is a function in the dynamic linking facilities of Unix-like systems. It provides a human-readable description of the most recent error reported by the dynamic linker when using dlopen, dlsym, or dlclose. The function is declared in the header dlfcn.h and is part of the standard dynamic linker interface on POSIX-compliant platforms. The returned message is intended for debugging and logging.

dlerror returns a pointer to a null-terminated string describing the last error. The string is kept per-thread,

If there is no error, the returned pointer is NULL. If an error occurred, the returned pointer

The error state is thread-local, allowing concurrent threads to report separate messages. The message is not

dlerror is available on most Unix-like systems, including Linux, macOS, and BSD variants. It is not part

and
it
should
not
be
freed
or
modified
by
the
program.
Importantly,
dlerror
only
remains
valid
until
the
next
call
to
dlerror.
A
common
usage
pattern
is
to
clear
any
existing
error
by
calling
dlerror()
before
calling
dlopen
or
dlsym,
then
perform
the
operation,
and
immediately
call
dlerror()
again
to
retrieve
the
error
message
if
one
occurred.
points
to
a
human-readable
message,
such
as
indicating
that
a
library
could
not
be
loaded
or
that
a
symbol
could
not
be
found.
The
exact
text
is
implementation-dependent
but
typically
describes
the
failure
cause.
guaranteed
to
remain
stable
across
subsequent
calls
to
dlerror;
if
you
need
to
retain
it,
copy
it
promptly.
of
the
Windows
API,
which
uses
a
different
dynamic
loading
mechanism.