Knowledge (XXG)

Shared library

Source 📝

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

Index

Shared libraries
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

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