C++ ld选项-lrt指的是什么库(仿生libc)?

C++ ld选项-lrt指的是什么库(仿生libc)?,c++,c,android-ndk,gdc,bionic,C++,C,Android Ndk,Gdc,Bionic,这个选项对ld意味着什么 -lrt 我知道在某种程度上这意味着ld正在寻找具有实时扩展的库,但在广泛搜索之后,我找不到它所指的确切定义(或哪个库) 通过仿生(android)libc,android NDK文档详细说明了它(以及pthreads)已经集成 我这样问是因为它似乎是隐式的(即当我直接调用编译器(一个自定义编译的gdc)时,我收到一条消息,说ld找不到-lrt) 编辑 从仿生概述 Bionic的C库附带了自己的pthread实现 在里面这与其他历史C库不同,后者: - place it

这个选项对ld意味着什么

-lrt

我知道在某种程度上这意味着ld正在寻找具有实时扩展的库,但在广泛搜索之后,我找不到它所指的确切定义(或哪个库)

通过仿生(android)libc,android NDK文档详细说明了它(以及pthreads)已经集成

我这样问是因为它似乎是隐式的(即当我直接调用编译器(一个自定义编译的gdc)时,我收到一条消息,说ld找不到-lrt)

编辑

从仿生概述

Bionic的C库附带了自己的pthread实现 在里面这与其他历史C库不同,后者:

- place it in an external library (-lpthread)
- play linker tricks with weak symbols at dynamic link time
对实时功能(又称lrt)的支持也被捆绑在一起 C库

问题是collect2正在将选项-lrt(以及-lpthreads)传递给ld


是否有方法覆盖此行为?

-l
是用于将库链接到最终可执行文件的标志。在这种情况下,所涉及的库是
librt.a
(或
librt.so
librt.dylib
,具体取决于您的系统)
librt
是实时扩展库。

当您看到
-lsomething
时,库名为
libsomething
。做一个
manlibrt
说明如下:

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.

回答我自己的问题:它是硬编码到gdc/d/d-spec.c中的,所以-L/path/to/libc应该帮助ld找到它?不,libc是c运行时库。rt是线程等也需要的实时扩展。对不起,这是你们需要和仿生人一起学习的东西。在Linux上,我们对librt.so和librt.a感到满意。但是对于初学者来说,如果您将Makefile更改为不使用-lrt--缺少符号或者它是构建的,会发生什么呢?它是由gdc在链接过程中隐式添加的。也就是说,我将尝试-v选项,并在返回到具有我正在使用的工具链的工作站时发布结果。不管怎样,谢谢你的回答。是的,但这是仿生的,不是glibc安装。我相信Bionic将libpthreads和librt集成到了libc中。请问它是什么版本的Unix/Linux?我试过RHEL和Ubuntu,但没有得到librt的
手动输入
我不记得了,很多年前我回答过:)但是值得注意的是,你可能没有安装手册页,因为Ubuntu上的手册页往往是一个独立的包。@dwerner在Solaris中,librt是libc上的“过滤器”,不管这意味着什么:“共享对象在libc.so.1上实现为筛选器。新的应用程序开发不需要指定–lrt。“也许Ubuntu也是如此。
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.