Knowledge

Shared library

Source 📝

413:. This problem cannot occur if each version of each library is uniquely identified and each program references libraries only by their full unique identifiers. The "DLL hell" problems with earlier Windows versions arose from using only the names of libraries, which were not guaranteed to be unique, to resolve dynamic links in programs. (To avoid "DLL hell", later versions of Windows rely largely on options for programs to install private DLLs—essentially a partial retreat from the use of shared libraries—along with mechanisms to prevent replacement of shared system DLLs with earlier versions of them.) 55: 25: 500:
and setgid programs, so that a user can't force such a program to run arbitrary code with root permissions. Developers of libraries are encouraged to place their dynamic libraries in places in the default search path. On the downside, this can make installation of new libraries problematic, and these
398:
Loaders for shared libraries vary widely in functionality. Some depend on the executable storing explicit paths to the libraries. Any change to the library naming or layout of the file system will cause these systems to fail. More commonly, only the name of the library (and not the path) is stored in
208:
Most modern operating systems use the same format for both shared libraries and executable files. This offers two main advantages: first, it requires only one loader (building and maintaining a single loader is considered well worth any added complexity). Secondly, it allows an executable file to be
372:
Since shared libraries on most systems do not change often, systems can compute a likely load address for each shared library on the system before it is needed and store that information in the libraries and executables. If every shared library that is loaded has undergone this process, then each
348:
when the executable file is created; it only records what library routines the program needs and the index names or numbers of the routines in the library. The majority of the work of linking is done at the time the application is loaded (load time) or during execution (runtime). Usually, the
519:
on request. Such a request may be made implicitly or explicitly. Implicit requests are made when a compiler or static linker adds library references that include file paths or simply file names. Explicit requests are made when applications make direct calls to an operating system's API.
467:
used a more flexible system, collecting a list of libraries from a number of known locations (similar to the PATH concept) when the system first starts. Moving libraries around causes no problems at all, although users incur a time cost when first starting the system.
204:
Shared libraries can be statically linked at compile-time, meaning that references to the library are resolved and the library is allocated memory when the executable file is created. But often linking of shared libraries is postponed until they are loaded.
289:
In some cases, different versions of shared libraries can cause problems, especially when libraries of different versions have the same file name, and different applications installed on a system each require a specific version. Such a scenario is known as
201:. For perspective, a program can alternatively be monolithic -- built to include the executable code of the library in its executable file, but the library code embedded in the program's executable file is not usable by other programs. 402:
If a shared library that an executable depends on is deleted, moved, or renamed, or if an incompatible version of the library is copied to a place that is earlier in the search, the executable would fail to load. This is called
353:. (However, it is possible, and not exceedingly difficult, to write a program that uses dynamic linking and includes its own dynamic linker, even for an operating system that itself provides no support for dynamic linking.) 381:
uses a similar technique, called "Discontinuous Saved Segments" (DCSS). Disadvantages of this technique include the time required to precompute these addresses every time the shared libraries change, the inability to use
262:
system, applications were often only a few hundred kilobytes in size and loaded quickly; most of their code was located in libraries that had already been loaded for other purposes by the operating system.
258:, and on disk. If virtual memory is used, processes would execute the same physical page of RAM that is mapped into the different address spaces of the processes. This has advantages. For instance, on the 278:. These systems ensure, by various means, like pre-mapping the address space and reserving slots for each shared library, that code has a high probability of being shared. A third alternative is 286:
and its successors. This allows position-dependent code, but places no significant restrictions on where code can be placed or how it can be shared.
440:
function; the System32, System, and Windows directories; then the current working directory; and finally the directories specified by the PATH
298:. Most modern operating systems after 2001 have clean-up methods to eliminate such situations or use application-specific "private" libraries. 492:
formats can specify additional directories in which to search for libraries for a particular program. This can usually be overridden with an
240:, only stack-based data (local) was allowed in shared library code, or other significant restrictions were placed on shared library code. 432:, but for other DLLs it will check the directories in a defined order. First, Windows checks the directory where it loaded the program ( 633: 739: 119: 771: 91: 386:, and the requirement of sufficient virtual address space for use (a problem that will be alleviated by the adoption of 523:
Most operating systems that support dynamically linked libraries also support dynamically loading such libraries via a
383: 373:
will load at its predetermined address, which speeds up the process of dynamic linking. This optimization is known as
98: 528: 524: 516: 321: 198: 183: 138: 399:
the executable, with the operating system supplying a method to find the library on disk, based on some algorithm.
72: 501:"known" locations quickly become home to an increasing number of library files, making management more complex. 105: 552: 233: 214: 76: 274:, which leads to a complex but flexible architecture, or by using common virtual addresses, as in Windows and 515:
Dynamic loading, a subset of dynamic linking, involves a dynamically linked library loading and unloading at
349:
necessary linking program, called a "dynamic linker" or "linking loader", is actually part of the underlying
87: 766: 649:
Private DLLs are DLLs that are installed with a specific application and used only by that application.
267: 152: 361: 344:
systems) is a library intended for dynamic linking. Only a minimal amount of work is done by the
65: 429: 193:
loads the shared library from a file (other than the program's executable file) into memory at
481: 449: 112: 637: 493: 441: 325: 8: 705: 255: 222: 179: 38: 731: 485: 345: 279: 213:). Examples of file formats use for both shared libraries and executable files include 661: 532: 421: 329: 484:
in which to look for dynamic libraries. Some systems specify the default path in a
425: 350: 190: 175: 409:, existing on many platforms. The (infamous) Windows variant is commonly known as 324:), rather than when the executable file is created. A dynamically linked library ( 510: 405: 171: 608: 445: 307: 229: 760: 588: 283: 249: 167: 313: 210: 489: 374: 189:
When running a program that is configured to use a shared library, the
151:"Shared object" redirects here. For the synchronization mechanism, see 477: 341: 317: 194: 54: 464: 453: 410: 295: 291: 259: 592: 357: 337: 237: 452:
as the primary store of shared dll files to remove the issue of
559:-based systems, including most UNIX and UNIX-like systems, use 497: 387: 218: 556: 378: 333: 275: 271: 428:
to determine the proper place to load DLLs that implement
16:
Code library designed for mutual use by multiple programs
356:
Programmers originally developed dynamic linking in the
316:
is linking performed while a program is being loaded (
488:, others hard-code it into the dynamic loader. Some 480:
systems have a "search path" specifying file-system
79:. Unsourced material may be challenged and removed. 571:. Some development systems automate this process. 360:operating system, starting in 1964, and the MTS ( 254:Library code may be shared in memory by multiple 758: 393: 703: 627: 625: 611:by Ulrich Drepper (with much background info) 390:architectures, at least for the time being). 266:Programs can accomplish RAM sharing by using 622: 707:Saved Segments Planning and Administration 139:Learn how and when to remove this message 631: 340:; dynamic shared object, or DSO, under 34:may need to be cleaned up or summarized 759: 436:); any directories set by calling the 377:on macOS and Linux, respectively. IBM 209:used as a shared library (if it has a 471: 416: 77:adding citations to reliable sources 48: 18: 736:Microsoft Developer Network Library 732:"Dynamic-Link Library Search Order" 662:"VSI OpenVMS Linker Utility Manual" 294:, named after the Windows and OS/2 228:In some older environments such as 13: 602: 504: 384:address space layout randomization 301: 36:because it has been split from/to 14: 783: 243: 553:Microsoft Dynamic Link Libraries 367: 174:designed to be used by multiple 53: 23: 742:from the original on 9 May 2012 636:. microsoft.com. Archived from 444:. Applications written for the 64:needs additional citations for 724: 697: 678: 654: 581: 496:, although it is disabled for 1: 687:Information Technology Digest 632:Anderson, Rick (2000-01-11). 615: 609:How To Write Shared Libraries 448:(since 2002), also check the 394:Locating libraries at runtime 364:), built in the late 1960s. 7: 772:Operating system technology 595:, also have a single format 459: 10: 788: 587:Some older systems, e.g., 508: 305: 247: 150: 738:. Microsoft. 2012-03-06. 268:position-independent code 153:Monitor (synchronization) 704:IBM Corporation (2011). 574: 375:prebinding or prelinking 362:Michigan Terminal System 336:; shareable image under 32:This article or section 535:uses the API functions 634:"The End of DLL Hell" 450:Global Assembly Cache 685:"A History of MTS". 494:environment variable 442:environment variable 326:dynamic-link library 73:improve this article 312:Dynamic linking or 39:Library (computing) 767:Computer libraries 667:. VSI. August 2019 486:configuration file 280:single-level store 533:Microsoft Windows 472:Unix-like systems 438:SetDllDirectory() 422:Microsoft Windows 417:Microsoft Windows 282:, as used by the 176:computer programs 149: 148: 141: 123: 47: 46: 779: 751: 750: 748: 747: 728: 722: 721: 719: 717: 712: 701: 695: 694: 682: 676: 675: 673: 672: 666: 658: 652: 651: 646: 645: 629: 596: 585: 570: 566: 562: 550: 546: 542: 538: 531:. For instance, 439: 351:operating system 328:, or DLL, under 191:operating system 144: 137: 133: 130: 124: 122: 88:"Shared library" 81: 57: 49: 27: 26: 19: 787: 786: 782: 781: 780: 778: 777: 776: 757: 756: 755: 754: 745: 743: 730: 729: 725: 715: 713: 710: 702: 698: 684: 683: 679: 670: 668: 664: 660: 659: 655: 643: 641: 630: 623: 618: 605: 603:Further reading 600: 599: 586: 582: 577: 568: 564: 560: 548: 544: 540: 536: 513: 511:Dynamic loading 507: 505:Dynamic loading 490:executable file 474: 462: 437: 419: 406:dependency hell 396: 370: 320:) or executed ( 310: 304: 302:Dynamic linking 252: 246: 172:executable code 156: 145: 134: 128: 125: 82: 80: 70: 58: 43: 28: 24: 17: 12: 11: 5: 785: 775: 774: 769: 753: 752: 723: 696: 677: 653: 620: 619: 617: 614: 613: 612: 604: 601: 598: 597: 579: 578: 576: 573: 549:GetProcAddress 509:Main article: 506: 503: 473: 470: 461: 458: 446:.NET Framework 418: 415: 395: 392: 369: 366: 308:Dynamic linker 306:Main article: 303: 300: 248:Main article: 245: 244:Memory sharing 242: 230:16-bit Windows 170:that contains 160:shared library 147: 146: 61: 59: 52: 45: 44: 31: 29: 22: 15: 9: 6: 4: 3: 2: 784: 773: 770: 768: 765: 764: 762: 741: 737: 733: 727: 709: 708: 700: 692: 688: 681: 663: 657: 650: 640:on 2001-06-05 639: 635: 628: 626: 621: 610: 607: 606: 594: 590: 589:Burroughs MCP 584: 580: 572: 558: 554: 541:LoadLibraryEx 534: 530: 526: 521: 518: 512: 502: 499: 495: 491: 487: 483: 479: 469: 466: 457: 455: 451: 447: 443: 435: 431: 427: 423: 414: 412: 408: 407: 400: 391: 389: 385: 380: 376: 368:Optimizations 365: 363: 359: 354: 352: 347: 343: 339: 335: 331: 327: 323: 319: 315: 309: 299: 297: 293: 287: 285: 284:IBM System/38 281: 277: 273: 269: 264: 261: 257: 251: 250:Shared memory 241: 239: 235: 231: 226: 224: 220: 216: 212: 206: 202: 200: 196: 192: 187: 185: 181: 177: 173: 169: 168:computer file 165: 164:shared object 161: 154: 143: 140: 132: 121: 118: 114: 111: 107: 104: 100: 97: 93: 90: –  89: 85: 84:Find sources: 78: 74: 68: 67: 62:This article 60: 56: 51: 50: 41: 40: 35: 30: 21: 20: 744:. Retrieved 735: 726: 714:. Retrieved 706: 699: 690: 686: 680: 669:. Retrieved 656: 648: 642:. Retrieved 638:the original 583: 522: 514: 475: 463: 433: 420: 404: 401: 397: 371: 355: 314:late binding 311: 288: 265: 253: 227: 211:symbol table 207: 203: 188: 163: 159: 157: 135: 126: 116: 109: 102: 95: 83: 71:Please help 66:verification 63: 37: 33: 545:FreeLibrary 537:LoadLibrary 482:directories 434:private DLL 430:COM objects 424:checks the 761:Categories 746:2012-05-20 671:2021-01-31 644:2012-01-15 616:References 99:newspapers 478:Unix-like 342:Unix-like 318:load time 256:processes 195:load time 180:libraries 178:or other 129:July 2023 740:Archived 525:run-time 465:OpenStep 460:OpenStep 454:DLL hell 426:registry 411:DLL hell 296:DLL file 292:DLL hell 270:, as in 260:OpenStep 236:for the 716:Jan 29, 593:Multics 565:dlclose 527:linker 517:runtime 358:Multics 338:OpenVMS 330:Windows 322:runtime 238:HP 3000 199:runtime 184:runtime 113:scholar 561:dlopen 498:setuid 388:64-bit 346:linker 221:, and 219:Mach-O 115:  108:  101:  94:  86:  711:(PDF) 665:(PDF) 575:Notes 569:dlsym 557:POSIX 551:with 476:Most 166:is a 120:JSTOR 106:books 718:2022 693:(5). 567:and 547:and 379:z/VM 334:OS/2 332:and 276:OS/2 272:Unix 92:news 529:API 234:MPE 232:or 215:ELF 197:or 182:at 162:or 75:by 763:: 734:. 689:. 647:. 624:^ 591:, 563:, 555:; 543:, 539:, 456:. 225:. 223:PE 217:, 186:. 158:A 749:. 720:. 691:5 674:. 155:. 142:) 136:( 131:) 127:( 117:· 110:· 103:· 96:· 69:. 42:.

Index

Library (computing)

verification
improve this article
adding citations to reliable sources
"Shared library"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
Monitor (synchronization)
computer file
executable code
computer programs
libraries
runtime
operating system
load time
runtime
symbol table
ELF
Mach-O
PE
16-bit Windows
MPE
HP 3000
Shared memory
processes

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.