C++Beginner(3)-Compile
2022/8/23 1:52:45
本文主要是介绍C++Beginner(3)-Compile,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
compiling
source code file(.cpp,.cxx,.cc,.C,.c++) -> object files(.o,.obj) -> link object files together into an executable (app.exe, app), static library(.lib, .a), or dynamic library(.dll, .so)
If any of the source code files changed, we recompile them to generate a new object file and then run the linker with all the unchanged object files too.
object file
a binary file that is specific to a particular version of a particular compiler configured with particular settings
If the compiler, version, or settings change, all the code needs to be rebuilt.
diff between a static library and a dynamic library
dynamic library: a library of machine code, just like an executable. it can be loaded and unloaded by an executable or other dynamic library at runtime.
static library: can only be loaded at compile time and can never be unloaded.
Because static libraries are available at build time, the linker builds them directly into the resulting executable.
Critically for performance, all calls into functions in the static library are just normal function calls. This means there’s no indirection through a pointer that is set at runtime when a dynamic library is loaded. It also means that the linker can perform “link time optimizations” such as inlining these functions.
The main downsides stem from needing the static libraries to be present at compile time. This makes them unsuitable for tasks such as loading user-created plugins. Perhaps most importantly for large projects, they must be linked in every build even if just one small source file was changed. Link times grow proportionally and can hinder rapid iteration. As a result, sometimes dynamic libraries will be used in development builds and static libraries will be used in release builds.
directives
ifndef MATH_H == if (!defined MATH_H)
pragma once
这篇关于C++Beginner(3)-Compile的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-23增量更新怎么做?-icode9专业技术文章分享
- 2024-11-23压缩包加密方案有哪些?-icode9专业技术文章分享
- 2024-11-23用shell怎么写一个开机时自动同步远程仓库的代码?-icode9专业技术文章分享
- 2024-11-23webman可以同步自己的仓库吗?-icode9专业技术文章分享
- 2024-11-23在 Webman 中怎么判断是否有某命令进程正在运行?-icode9专业技术文章分享
- 2024-11-23如何重置new Swiper?-icode9专业技术文章分享
- 2024-11-23oss直传有什么好处?-icode9专业技术文章分享
- 2024-11-23如何将oss直传封装成一个组件在其他页面调用时都可以使用?-icode9专业技术文章分享
- 2024-11-23怎么使用laravel 11在代码里获取路由列表?-icode9专业技术文章分享
- 2024-11-22怎么实现ansible playbook 备份代码中命名包含时间戳功能?-icode9专业技术文章分享