简体   繁体   English

库是否包含在预处理器或链接中

[英]Are Libraries included at preprocessor or linking

When you build an executable in C++, when including header files当您在 C++ 中构建可执行文件时,当包含头文件时

For example, #include <iostream>例如, #include <iostream>

Does the Preprocessor find the library iostream library and the function used or is the object code for the library functions injected at Linking?预处理器是否找到了库 iostream 库和使用的函数,或者是在链接时注入的库函数的目标代码?

All #include does is load in the definitions of the library functions and doesn't have anything to do with the binary instance of library itself. #include所做的只是加载库函数的定义,与库本身的二进制实例没有任何关系。

Think of the header files as blueprints on how the library works, but does not provide the actual components that the program needs.将头文件视为库如何工作的蓝图,但不提供程序所需的实际组件。 It's just so the compiler can understand how the library works.这只是为了让编译器能够理解库是如何工作的。

In order for that to come into play you must also link in the associated library files.为了发挥作用,您还必须链接相关的库文件。 This is done with different arguments at the linking stage.这是在链接阶段使用不同参数完成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM