更新时间:2023-11-30 22:15:46
在功能文件stdlib.h
和 stdio.h中
在 libc.so
实现(或的libc.a
静态链接),它链接到您的在默认情况下的可执行文件(就像 -lc
中指定)。 GCC可以指示避免这种自动链接 -nostdlib
或 -nodefaultlibs
选项。
The functions in stdlib.h
and stdio.h
have implementations in libc.so
(or libc.a
for static linking), which is linked into your executable by default (as if -lc
were specified). GCC can be instructed to avoid this automatic link with the -nostdlib
or -nodefaultlibs
options.
在文件math.h
数学函数在 libm.so
实现(或 libm.a
静态链接),而的libm
默认情况下不链接英寸这有的libm
/ 的libc
分裂历史的原因,他们没有非常有说服力的。
The math functions in math.h
have implementations in libm.so
(or libm.a
for static linking), and libm
is not linked in by default. There are historical reasons for this libm
/libc
split, none of them very convincing.
有趣的是,C ++运行时的libstdc ++
要求的libm
,因此,如果您编译C ++程序与海湾合作委员会( G ++
),您将自动获得的libm
的链接。
Interestingly, the C++ runtime libstdc++
requires libm
, so if you compile a C++ program with GCC (g++
), you will automatically get libm
linked in.