cc [flag . . . ] file . . . -lelf [library] . . .#include <libelf.h>
const char elf_errmsg(int err); int elf_errno(void);
elf_errmsg takes an error number, err, and returns a null-terminated error message (with no trailing new-line) that describes the problem. A zero err retrieves a message for the most recent error. If no error has occurred, the return value is a null pointer (not a pointer to the null string). Using err of -1 also retrieves the most recent error, except it guarantees a non-null return value, even when no error has occurred. If no message is available for the given number, elf_errmsg returns a pointer to an appropriate message. This function does not have the side effect of clearing the internal error number.
(void)elf_errno(); while (more_to_do) { / processing ... / if ((err = elf_errno()) != 0) { msg = elf_errmsg(err); / print msg / } }