问题描述
我有一个名为 main.cpp
的文件,其中包含 iostream
。
I have a file named main.cpp
which includes iostream
.
我编译了 main.cpp
,它没有错误,所以我的问题是:我编译 main.cpp
并且我没有链接 iostream
与 main.cpp
,那么怎么可能?或者编译器是否自动链接 iostream
?
I compiled main.cpp
and it worked without errors, so my question is: I compiled main.cpp
and I did not link iostream
with main.cpp
, so how could this be possible? Or did the compiler linked the iostream
automatically?
推荐答案
iostream
是C ++标准库的一部分,您通常不需要明确链接。
The functions in iostream
are part of the C++ standard library, which you usually don't need to link explicitly.
使用不是严格的C ++编译器的编译器,你有时需要添加类似 -lstdc ++
(至少,如果我使用 gcc
而不是
g ++
)。
If you use a compiler that's not strictly a C++ compiler, you sometimes need to add something like -lstdc++
(at least, I do if I use gcc
rather than g++
).
这篇关于c ++链接器,如何链接iostream文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!