---
name: "elf_version"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_version"
---

# elf\_version(3)

retrieve or set ELF library operating version

## NAME

**elf\_version** – retrieve or set ELF library operating version

## LIBRARY

library “libelf”

## SYNOPSIS

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

*unsigned* *int*\

**elf\_version**(*unsigned int version*);

## DESCRIPTION

The **elf\_version**() function is used to query the current operating version of the ELF library, and to inform the ELF library about the application's desired operating version.

If the argument *version* is EV\_NONE, the **elf\_version**() function returns the currently configured operating version for the ELF library.

If the argument *version* is not EV\_NONE, and if argument *version* is supported by the ELF library, function **elf\_version**() sets the library's operating version to *version*, and returns the previous value of the operating version. If argument *version* cannot be supported, then the **elf\_version**() function returns EV\_NONE.

## RETURN VALUES

The **elf\_version**() function returns the currently configured ELF library version, or EV\_NONE if an unsupported version is requested.

## EXAMPLES

An application program would inform the ELF library about its desired operating version and check for an error using the following code snippet:

```
if (elf_version(EV_CURRENT) == EV_NONE)
	err(EXIT_FAILURE, "ELF library too old");
```

## ERRORS

Function **elf\_version**() may fail with the following error:

- \[ELF\_E\_VERSION\]

  An unsupported library version number was requested.

## SEE ALSO

[elf(3)](/elf/3.md), [gelf(3)](/gelf/3.md)
