uselib(2)
๐ uselib โ load shared library ๐
okay bestie, gather round, because we're talking about uselib(2), a genuine fossil of a system call from the System Calls Manual. it loads a shared library. that's the whole job. it's giving "vintage", it's giving "why is this still in the kernel", and yes, it is deprecated. let's get into it ๐
โจ SYNOPSIS โจ
#include <unistd.h>
[[deprecated]] int uselib(const char *library);
see that [[deprecated]] right there? that's the compiler side-eyeing you. respect it.
๐ฆ DESCRIPTION ๐ฆ
okay so here's the tea. the system call uselib() serves to load a shared library to be used by the calling process. that's its whole personality.
you hand it a pathname โ that's your library. and the address of where to actually load it? not your problem, babes. the address where to load is found in the library itself. iconic behaviour honestly.
also, the library can have any recognized binary format. so whatever format the system recognizes, it's valid. no gatekeeping ๐
๐ RETURN VALUE ๐
- on success, zero is returned. slay.
- on error,
-1is returned, anderrnois set to indicate the error. yeah, the classic-1+errnocombo, we've all been there ๐ญ
๐ ERRORS ๐
so in addition to all of the error codes returned by open(2) and mmap(2) (yes, all of them, go read those pages too, i'm not doing your homework for you), the following may also be returned:
EACCESโ the library specified bylibrarydoes not have read or execute permission, or the caller does not have search permission for one of the directories in the path prefix. (see alsopath_resolution(7).) basically the vibes were denied at the door ๐ซENFILEโ the system-wide limit on the total number of open files has been reached. too many files open, the whole system is overstimulated, no more for anyone ๐ENOEXECโ the file specified bylibraryis not an executable of a known type; for example, it does not have the correct magic numbers. the โจmagicโจ is wrong. sorry bestie, that's not a real executable ๐ฎ
โญ STANDARDS โญ
Linux. that's it. that's the standard. Linux ๐ง
๐ HISTORY ๐
okay this is the part where it gets really good, because the lore is unhinged:
- this obsolete system call is not supported by glibc. no declaration is provided in glibc headers. BUT โ and this is the quirk of history i'm obsessed with โ glibc before glibc 2.23 did export an ABI for this system call. the way that glibc just quietly kept an ABI lying around?? ๐
- therefore, in order to employ this system call, it was sufficient to manually declare the interface in your code; alternatively, you could invoke the system call using
syscall(2). DIY era fr fr. - in ancient libc versions (before glibc 2.0),
uselib()was used to load the shared libraries with names found in an array of names in the binary. ancient. prehistoric. archaeological ๐ฆ - since Linux 3.15, this system call is available only when the kernel is configured with the
CONFIG_USELIBoption. so if your kernel didn't check that box, this call simply does not exist for you. no cap.
๐ธ SEE ALSO ๐ธ
go read those, bestie, you'll be so smart ๐ซถ
and that's the whole page!! this edition of the documentation came from Linux man-pages 6.20, dated 2026-02-08, and it's been an absolute pleasure doing fossil restoration with you ๐โจ๐ mwah, go write some code, you main character ๐๐๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1992, Drew Eckhardt <drew@cs.colorado.edu>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms