dlerror() — Get diagnostic information


Standards / Extensions C or C++ Dependencies
Single UNIX Specification, Version 3
both z/OS® V1R6


#define _UNIX03_SOURCE
#include <dlfcn.h>

void  dlerror(void);

General description

Returns a null-terminated character string (with no trailing <newline>) that describes the last error that occurred while processing a DLL by dlopen(), dlsym(), or dlclose(). NULL is returned if no errors have occurred since the last invocation of dlerror().
Note: dlerror() is thread safe, so the information returned describes the last error that occurred on that thread

Returned value

A null-terminated character string is returned if successful, otherwise NULL is returned.

Usage notes

  1. Messages returned by dlerror() reside in a static buffer that is overwritten on each new call to dlerror() on that thread.
  2. Application code should not write to this buffer.
  3. Programs wishing to preserve an error message should make their own copies of that message.
  4. This function is not available under SPC, MTF and CSP environments.


The following example prints out the last dynamic linking error:
#include <dlfcn.h>

char *errstr;

errstr = dlerror();
if (errstr != NULL)
printf ("A dynamic linking error occurred: (%s)\n", errstr);

Related information