ldconfig(8)

ldconfig8

Configure the dynamic linker search path for shared libraries

Usage

ldconfig [-32] [-BRimr] [-f hints_file] [{directory | file ...}]

Overview

ldconfig utility is used to configure the set of paths used by the dynamic linker ld-elf.so.1(1) when searching for shared libraries. The dynamic linker looks for libraries in a set of built-in system directories and any directories specified in the hints file. This obviates the need for storing search paths within the executable, see the -rpath option for the static linker ld(1).

The hints file is maintained by ldconfig. The directories list to be stored in the hints file is supplied on the command line.

Alternatively to the directories list on the command line, files may be specified; these are expected to contain directories to scan for shared libraries. Each directory's pathname must start on a new line. Blank lines and lines starting with the comment character ‘#’ are ignored.

For security reasons, directories which are world or group-writable or which are not owned by root produce warning messages and are skipped, unless the -i option is present.

The LD_LIBRARY_PATH environment variable can be used to specify additional shared library search directories. LD_LIBRARY_PATH is a ‘:’ separated list of directory paths which are searched by the dynamic linker when it needs to load a shared library. It can be viewed as the run-time equivalent of the -L switch of ld(1).

The following options are recognized by ldconfig:

-32

Generate the hints for 32-bit ABI shared libraries on 64-bit systems that support running 32-bit binaries.

Not on Linux or OpenBSD.
-elf

Ignored for backwards compatibility.

Not on Linux or OpenBSD.
-B

Force writing big-endian binary data to the hints file. The default is to create hints files in little-endian byte-order on all architectures. Reading of and merging into hints files preserves the endianness of the existing hints file.

Not on Linux or OpenBSD.
-R

Appends pathnames on the command line to the directory list from the hints file.

This is the default action when no options are given.

Not on Linux.
-f hints_file

Read and/or update the specified hints file, instead of the standard file. This option is provided primarily for testing.

Not on OpenBSD.
-i

Run in insecure mode. The security checks will not be performed.

Not on OpenBSD. As --ignore-aux-cache, -i on Linux.
-m

Instead of replacing the list of the directories to search with the directories specified on the command line, merge existing list with the specified directories, and write the result to the hints file.

Not on Linux.
-r

List the current list of the directories from the hints file on the standard output. The hints file is not modified.

Scan and print all libraries found on the directories list.

The historic options -elf, -s, and -v are accepted but ignored.

Security

Special care must be taken when loading shared libraries into the address space of set-user-Id programs. Whenever such a program is run by any user except the owner of the program, the dynamic linker will only load shared libraries from paths found in the hints file. In particular, the LD_LIBRARY_PATH is not used to search for libraries. Thus, ldconfig serves to specify the trusted collection of directories from which shared objects can be safely loaded.

Files

/var/run/ld-elf.so.hints

Standard hints file for the ELF dynamic linker.

/var/run/ld-elf32.so.hints

Hints file for 32 bit libraries on 64 bit architectures, processed by ldconfig when invoked with -32.

/etc/ld-elf.so.conf

Optional file with names of directories to be included in the standard hints file when booting to multi-user mode.

/usr/local/libdata/ldconfig/*

Additional files with names of directories provided by optional ports or packages.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 55 times.

  1. 2.0.5
  2. 2.1.5–2.1.7.1
  3. 2.2.2
  4. 2.2.5
  5. 2.2.6–2.2.8
  6. 2.2.9
  7. 3.0–3.2
  8. 3.3–3.4
  9. 3.5–3.5.1
  10. 4.0
  11. 4.1–4.2
  12. 4.3
  13. 4.4–4.6.2
  14. 4.7
  15. 4.8
  16. 4.9–4.11
  17. 5.0
  18. 5.1–5.2.1
  19. 5.3–6.0
  20. 6.1–6.3
  21. 6.4
  22. 7.0
  23. 7.1
  24. 7.2
  25. 7.3
  26. 7.4
  27. 8.0
  28. 8.1
  29. 8.2
  30. 8.3
  31. 8.4
  32. 9.0
  33. 9.1
  34. 9.2
  35. 9.3
  36. 10.0
  37. 10.1
  38. 10.2
  39. 10.3
  40. 10.4
  41. 11.0
  42. 11.1
  43. 11.2
  44. 11.3
  45. 11.4
  46. 12.0
  47. 12.1
  48. 12.2
  49. 12.3
  50. 12.4
  51. 13.0
  52. 13.1–13.2
  53. 13.3–14.0
  54. 14.1–14.2
  55. 14.3–14.5
  56. 15.0–16.0

-32 since FreeBSD 6.1-RELEASE; -B since FreeBSD 14.1-RELEASE; -R since FreeBSD 2.2.6-RELEASE; -elf since FreeBSD 3.0-RELEASE; -f since FreeBSD 2.2.2-RELEASE; -i since FreeBSD 4.3-RELEASE; -m since FreeBSD 2.1.5-RELEASE.

-aout until FreeBSD 12.4-RELEASE; -s until FreeBSD 13.0-RELEASE; -v until FreeBSD 14.0-RELEASE.

History

A ldconfig utility first appeared in SunOS 4.0, it appeared in its current form in FreeBSD 1.1.

The name 'hints file' is historic from the times when the file also contained hints to the dynamic linker. This functionality is not provided for ELF.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.