标准内容的库(即:cout 等)*新问题* :)

发布于 2024-09-08 06:59:19 字数 242 浏览 2 评论 0原文

我想知道包含所有函数/定义的标准 C 库,如abs()、cout 流、printf 等。

我熟悉头文件(stdio.h、cmath.h、time.h 等) )但似乎没有任何相应的 .lib 或 .dll (即 stdio.lib、time.dll 等)。

这些头文件中函数的实际代码在哪里?我误解了什么吗?是否有一个巨大的 lib 文件包含所有标准化内容,或者每个标头都有一个?

任何帮助表示赞赏!

谢谢!

I was wondering about the standard C libraries that contain all the functions/definitions like abs(), cout streams, printf, etc.

I'm familiar with the header files (stdio.h, cmath.h, time.h, etc etc) but there doesn't seem to be any corresponding .lib or .dll anywhere (ie. stdio.lib, time.dll, etc).

Where is the actual code for the functions in these header files? Am I misunderstanding something? Is there like, one huge lib file that contains all the standardized stuff, or one for each header?

Any help appreciated!!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

甜是你 2024-09-15 06:59:19

这取决于实施。在 Windows 上,标准库功能位于 C和 C++ 运行时库。 C 运行时库始终自动链接;如果包含标准库头文件之一,C++ 运行时库会自动链接。

It depends on the implementation. On Windows, the standard library functionality is in the C and C++ runtime libraries. The C runtime library is always linked in automatically; the C++ runtime library is linked in automatically if you include one of the standard library headers.

阳光下的泡沫是彩色的 2024-09-15 06:59:19

如果您使用的是 Linux/UNIX/AIX 的某些变体,请尝试使用 ldd 。只是为了在 Linux 提示符中的 ldd `which ls` 中尝试一些新类型的乐趣。这就是我得到的:

librt.so.1 => /lib/tls/librt.so.1 (0x0084c000)
libacl.so.1 => /lib/libacl.so.1 (0x40022000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00289000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a0b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00c57000)
/lib/ld-linux.so.2 (0x009ec000)
libattr.so.1 => /lib/libattr.so.1 (0x40028000)

路径应该告诉您从共享库中获取的位置。
如果您使用的是 Windows,请获取 dependent.exe http://www.dependencywalker.com --优秀的工具

If you are on Linux/some variant of UNIX/AIX try using ldd . Just for the fun of trying something new type in ldd `which ls` in your Linux prompt. Here's what I got:

librt.so.1 => /lib/tls/librt.so.1 (0x0084c000)
libacl.so.1 => /lib/libacl.so.1 (0x40022000)
libselinux.so.1 => /lib/libselinux.so.1 (0x00289000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a0b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00c57000)
/lib/ld-linux.so.2 (0x009ec000)
libattr.so.1 => /lib/libattr.so.1 (0x40028000)

The paths should tell you where from the shared libraries are being picked up.
If you are using Windows, get hold of depends.exe http://www.dependencywalker.com -- excellent tool

木森分化 2024-09-15 06:59:19

您通常不必显式链接 C 或 C++ 运行时库。通常编译器会使用正确的选项调用链接器来为您完成此操作。

事实上,使用 gcc,您必须采取一些措施来包含默认库(例如使用 -nodefaultlibs-nostdlib-nostartfiles)。

标准库的实际位置,包括它是否在单个文件中,是一个实现问题。

You generally don't have to explicitly link the C or C++ runtime libraries in. Usually the compiler will call the linker with the correct options to do it for you.

In fact, with gcc, you have to do something to not include the default libraries (such as using -nodefaultlibs, -nostdlib or -nostartfiles).

The actual location of the standard library, including whether or not it's in a single file, is an implementation issue.

看海 2024-09-15 06:59:19

正如 Arpan 提到的,您可以使用 ldd(位于“binutils”包中)来发现 libc 实际使用的 SO 文件。 Linux 系统上最常见的实现是 GNU C 库,通常称为 glibc。

As Arpan mentioned, you can use ldd (which is in the 'binutils' package) to discover what SO file is actually being used for libc. The most common implementation on Linux systems is the GNU C library, usually called glibc.

奈何桥上唱咆哮 2024-09-15 06:59:19

如果您提到 DLL,我假设您使用的是 Windows。在这种情况下,编译器通常会附带一个“运行时”DLL。对于 Visual C++,我相信该名称是 msvcrt.dll 或类似名称。

If you mention DLL's, I assume you are using Windows. In this case, there is usually one "runtime" DLL shipped with compiler. With Visual C++, I believe the name is msvcrt.dll or similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文