What library does ld option -lrt refer to (Bionic libc)?

前端 未结 3 2001
后悔当初
后悔当初 2020-12-09 02:13

What does this option to ld mean?

-lrt

I know to some degree it means that ld is looking for the library with real-time extensions, but after se

相关标签:
3条回答
  • 2020-12-09 02:29

    When you see a -lsomething, the library name is libsomething. Doing a man librt says the following:

    NAME
         librt, libposix4 - POSIX.1b Realtime Extensions library
    
    SYNOPSIS
         cc [ flag... ] file... -lrt [ library... ]
    
    DESCRIPTION
         Functions in this library provide  most  of  the  interfaces
         specified  by  the  POSIX.1b  Realtime Extension.  See stan-
         dards(5). Specifically, this includes the interfaces defined
         under   the   Asynchronous  I/O,  Message  Passing,  Process
         Scheduling, Realtime Signals Extension,  Semaphores,  Shared
         Memory  Objects,  Synchronized  I/O, and Timers options. The
         interfaces defined under the Memory  Mapped  Files,  Process
         Memory  Locking,  and  Range Memory Locking options are pro-
         vided in libc(3LIB)
    
         See the man pages for the individual interfaces  in  section
         3RT for information on required headers.
    
         The name libposix4 is maintained for backward  compatibility
         and  should be avoided. librt is the preferred name for this
         library.
    
    0 讨论(0)
  • 2020-12-09 02:30

    Answering my own question: it was hardcoded into gdc/d/d-spec.c

    0 讨论(0)
  • 2020-12-09 02:44

    -l is the flag used to link a library into your final executable. In this case, the library in question is librt.a (or librt.so or librt.dylib, depending on your system). librt is the realtime extensions library.

    0 讨论(0)
提交回复
热议问题