---
name: "elf_errmsg"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_errmsg"
---

# elf\_errmsg(3)

return the error message string for a given libelf error code.

## NAME

elf\_errmsg - return the error message string for a given libelf error code.

## SYNOPSIS

**#include \<libelf.h\>**

**const char \*elf\_errmsg(int** *err***);**

## DESCRIPTION

The **elf\_errmsg** function retrieves a human-readable string corresponding to the most recent error code set by a libelf library function. If *err* is 0, the function returns the error message for the most recent error code. If *err* is non-zero, the function returns the error message for the specified error code.

## PARAMETERS

- *err*

  An *int* value specifying the error code. If this value is 0, the function returns the error message for the most recent error or NULL if none occurred. If this value is -1, the behaviour is similar to the previous case except that a legal string will be returned instead of NULL.

## RETURN VALUE

The **elf\_errmsg** function returns a string containing the error message. If there is no corresponding error message, it returns NULL.

## SEE ALSO

[**elf\_errno**(3)](/elf_errno/3.md)

## REPORTING BUGS

Report bugs to \<elfutils-devel@sourceware.org\> or https://sourceware.org/bugzilla/.
